Here is an example of my code:
function blah()
{
var xmlHttp = (window.XMLHttpRequest) ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
xmlHttp.onreadystatechange = function()
{
if (xmlHttp.status == 200 && xmlHttp.readyState == 4)
alert(xmlHttp.responseText);
}
xmlHttp.open("GET", "ajax.php?_=" + new Date().getTime(), true);
xmlHttp.send();
}
It seems to work find in Chrome but IE8 throws an “Unsepcified Error” on the if status = 200 and readyState = 4 line.
Oddly, though, the alert does give the response from the php page.
Any ideas why this might be happening?
Maybe checking status if readyState != 4 causes the error in IE?
Try