MyBB Community Forums

Full Version: AJAX Nightmares
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have the following function that is supposed to load in a text file and display it in a div.

<script type="text/javascript">
function loadXMLDoc()
{
url='stest.txt';

if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
document.getElementById('test').innerHTML=xmlhttp.responseText;
}

</script>

No problems so far but the text file also contains some html that I also want included but all I get is the text itself.

Basically I have a something like this..

<table>

<div id="test"></div>

</table>

The div, which gets its content from the function, is supposed to not only contain the text but the rest of the html table tags etc.

The text file may contain something like..

<tr><td>Some text here</td></tr>
<tr><td>Some more text here</td></tr>

But all I get is

Some text hereSome more text here

It seems that the function is stripping out all html tags. Strangely enough it works fine in Opera but not in anything else Confused

Any ideas anyone?
I haven't tried to replicate, but I doubt it'd be removing the tags unless specified. It's most likely just bad HTML practice on your part (putting table rows inside a div, and putting a div inside a table). As a result most browsers render it as just the text.

Try your HTML removing the div:

<table id="test">

</table>
Also, if you want it to be on diffrent lines use<br />. That would be a good test to see if it is striping all tags.