I have the following piece of code:
// setup the AJAX request
var pageRequest = false;
if(window.XMLHttpRequest) pageRequest = new XMLHttpRequest();
else if(window.ActiveXObject) pageRequest = new ActiveXObject("Microsoft.XMLHTTP");
// callback
pageRequest.onreadystatechange = function() {
alert('pageRequest.readyState: ' + pageRequest.readyState
+ '\npageRequest.status: ' + pageRequest.status);
}
pageRequest.open('POST','ajax.php',true);
// q_str contains something like 'data=value...'
pageRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
pageRequest.setRequestHeader("Content-length", q_str.length);
pageRequest.setRequestHeader("Connection", "close");
pageRequest.send(q_str);
This works fine in Chrome, but IE chokes on it, spitting out an "Unspecified error." and it points to the line with the alert() in it. Why can't it display the alert?
Edit: Okay, after I dismiss the error dialog, I get the three alerts as expected....
Edit: Now it's really getting weird. If I change
alert('pageRequest.readyState: ' + pageRequest.readyState
+ '\npageRequest.status: ' + pageRequest.status);
to
alert('pageRequest.readyState: ' + pageRequest.readyState);
then it works and I get 5 alerts. (1,1,2,3,4)