Ajax Asynchronous in IE - Error "The Data Necessary to Complete This Operation is Not Yet Available"

Posted by Supernovah on Stack Overflow See other posts from Stack Overflow or by Supernovah
Published on 2008-12-19T03:20:34Z Indexed on 2010/03/31 9:03 UTC
Read the original article Hit count: 761

Hey there. I have a 100% valid Ajax model written in Javascript with a few inputs I use being, Get or Post method, What page to communicate with, What String to send to that page and What element on my own page I might be fiddling with when I receive my response. The problem is that, should I set the request to Asynchronous (Hence Ajax), IE returns the error "The Data Necessary to Complete This Operation is Not Yet Available" in the onreadystatechange event where all I do is check if the readystate is 4 and the status is 200. The error doesn't come up in Firefox or Chrome as I would exepect as the Ajax is Asynchronous.

Heres a snippet from the Post method

xmlhttp.open("POST", commPage, true);
xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
xmlhttp.onreadystatechange = function() {
    if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
        j = xmlhttp.responseText;
        i.innerHTML = j;
    }
}
xmlhttp.send(str);

Edit: I should point out that in IE, I'm using the ActiveX Control -> Msxml2.XMLHTTP or Microsoft.XMLHTTP or whichever returns true first.

© Stack Overflow or respective owner

Related posts about AJAX

Related posts about JavaScript