Javascript AJAX function not working in IE?

Posted by Sam152 on Stack Overflow See other posts from Stack Overflow or by Sam152
Published on 2009-04-17T14:27:47Z Indexed on 2010/05/29 0:42 UTC
Read the original article Hit count: 258

I have this code:

function render_message(id)
{
var xmlHttp;
  xmlHttp=new XMLHttpRequest();  
  xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)
      {
    	document.getElementById('message').innerHTML=xmlHttp.responseText;
    	document.getElementById('message').style.display='';
    	}
    }
    var url="include/javascript/message.php";
    url=url+"?q="+id;
  xmlHttp.open("GET",url,true);
  xmlHttp.send(null);
}

For some reason it does not work in IE and an error is being reported on this line "document.getElementById('message').innerHTML=xmlHttp.responseText;" with an "Unknown Runtime Error".

Can anyone help?

Edit: The code being added to the div is valid code ect.

Here is the response:

<div style="margin-left:auto;margin-right:auto;width:400px;">
    <img src="/forum/img/avatars/2.gif" width="90" height="89" style="float:left;">
    <div style="margin-left:100px;">
    	<span style="font-size:16pt;">Sam152</a></span><br>
    	<span style="font-size:10pt;text-transform:uppercase;font-weight:bold;">From Sam152</span><br>
    	<span style="font-size:10pt;font-weight:bold;">Recieved April 17, 2009, 9:44 am</span><br>
    	<br><br>

    </div>
</div>
<div style="margin-left:auto;margin-right:auto;width:400px;">
    	asd</div>
<div style="margin-left:auto;margin-right:auto;width:400px;text-align:right;padding-top:10px;">
    	<span onClick="requestPage('http://www.gametard.com/include/scripts/delete_message.php?id=14');document.getElementById('message14').style.display='none';document.getElementById('message').style.display='none';" class="button">Delete</span>
    	<span onClick="document.getElementById('message').style.display='none';" class="button">Close</span>
    	<span onClick="document.getElementById('to').value ='Sam152';document.getElementById('to').style.color ='#000';document.getElementById('newmessage').style.display='';" class="button">Reply</span>		

</div>

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about internet-explorer