最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin0浏览0评论

I have a 100% valid Ajax model written in Javascript with a few inputs I use being, Get or Post method, What page to municate 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 e up in Firefox or Chrome as I would exepect as the Ajax is Asynchronous.

Heres a snippet from the Post method

xmlhttp.open("POST", mPage, 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.

I have a 100% valid Ajax model written in Javascript with a few inputs I use being, Get or Post method, What page to municate 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 e up in Firefox or Chrome as I would exepect as the Ajax is Asynchronous.

Heres a snippet from the Post method

xmlhttp.open("POST", mPage, 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.

Share Improve this question edited Dec 19, 2008 at 3:25 Supernovah asked Dec 19, 2008 at 3:20 SupernovahSupernovah 2,05412 gold badges35 silver badges51 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 1

Ho humm

Outside of the onreadystatechange function I had a call for responsetext to check whether it existed yet, but aparently you can't do that if it doesn't exist yet so I just had to restructure some thigs. All is okay but this was the script that caused the problem

ajaxRequest(){
    [...]
}
if(xmlhttp.responseText){
    myFunc();
}

Once I had that error, and i solve it configuring the timeouts! maybe you could try the same thing!

Cheers

Not sure if that's your case but I've just been struggling with this error for three hours until I found the problem. The web service class wasn't decorated with ScriptService attribute that allows methods to be called from client script! I wouldn't blame IE because IE is just strict on errors and reports everything what other browsers ignore. IE is good for debugging. Hope this helps. Well... probably not you as your post is now very old.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论