I’m having trouble getting the follow code to work in Internet Explorer, it doesn’t seem to want to execute the code sent back from the server via Ajax, it just does nothing:
var ajax = new ActiveXObject('Microsoft.XMLHTTP');
ajax.open('GET','http://fromsitewebsite.com/javascript.js',true);
ajax.setRequestHeader('Connection','close');
ajax.onreadystatechange = function()
{
if ( ajax.readyState == 4 )
{
document.body.innerHTML += '<script type="text/javascript">'+ajax.responseText+'</script>';
}
};
ajax.send('');
I’ve tried doing this with still no luck;
document.body.innerHTML += '<script type="text/javascript">('+ajax.responseText+')()</script>')
Cheers
To get IE to handle the content of the script tag properly, you need to set the .text value.