IE 9 JavaScript 错误 c00c023f

发布于 2024-12-02 23:53:31 字数 990 浏览 0 评论 0原文

我只在 IE9 上遇到这个错误:

SCRIPT575:由于错误 c00c023f,无法完成操作。

错误发生在这一行: if ((a.responseXML) && (a.readyState==4)) {

我无法弄清楚为什么会发生这种情况,而且它似乎非常有效在其他浏览器中也很好。

这是我的 JavaScript 代码:

var a = new XMLHttpRequest();
a.open("GET",'/cust/ajax/getresult.php?qk=nnf87&arg1='+pzid,true);
a.onreadystatechange = function () {
    if ((a.responseXML) && (a.readyState==4)) {
        var N = a.responseXML.getElementsByTagName('result')
        sequence = N[0].firstChild.data;
        var SEQ = sequence.split(",");
        var num = SEQ.length;
                    var sum = 0;
                    for(var n=0;n<num;n++){sum = sum + (SEQ[n]*1);}
        //document.getElementById("the_number_of").innerHTML = sum;
        var date = new Date();
        date.setTime(date.getTime()+(2*60*60*1000));
        document.cookie='cpa_num='+sum+'; expires= '+date.toGMTString()+'; path=/';
    }

}

I came across this error only on IE9:

SCRIPT575: Could not complete the operation due to error c00c023f.

The error happened on this line: if ((a.responseXML) && (a.readyState==4)) {

I cant figure it out why this happened, and it seems to work very well in other browsers.

and this is my javascript code:

var a = new XMLHttpRequest();
a.open("GET",'/cust/ajax/getresult.php?qk=nnf87&arg1='+pzid,true);
a.onreadystatechange = function () {
    if ((a.responseXML) && (a.readyState==4)) {
        var N = a.responseXML.getElementsByTagName('result')
        sequence = N[0].firstChild.data;
        var SEQ = sequence.split(",");
        var num = SEQ.length;
                    var sum = 0;
                    for(var n=0;n<num;n++){sum = sum + (SEQ[n]*1);}
        //document.getElementById("the_number_of").innerHTML = sum;
        var date = new Date();
        date.setTime(date.getTime()+(2*60*60*1000));
        document.cookie='cpa_num='+sum+'; expires= '+date.toGMTString()+'; path=/';
    }

}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

壹場煙雨 2024-12-09 23:53:31

我不认为你的请求被中止了?快速谷歌搜索发现了这篇博客文章。当尝试从 XMLHttpRequest 对象读取任何属性时,IE9 中的中止请求似乎会出现此错误。

从帖子中可以看出,他们与此错误代码相关的特定问题可以通过以下方式重复:

  • 创建 XMLHttpRequest 对象
  • 分配 onreadystatechanged 事件处理程序
  • 执行请求
  • 在处理响应之前中止请求

您现在将看到将调用readystatechange处理程序,
就绪状态属性设置为“4”。任何尝试阅读
XmlHttpRequest 对象属性将失败。

作者通过在执行手动中止时为请求分配中止状态,并在尝试读取任何其他属性之前检测并返回来缓解此问题。尽管这种方法只有在您自己执行中止时才真正有效。

这篇 WebSync Google 网上论坛帖子。在讨论快要结束时,暗示这个问题只会发生

如果你有标准和 IE9 渲染
模式均已设置

希望为您指明正确的方向。

I don't suppose your request is being aborted? A quick Googling found this blog post. It would seem that an aborted request in IE9 will give this error when trying to read any properties off of the XMLHttpRequest object.

From the post, their particular problem with this error code could be duplicated by:

  • Create a XMLHttpRequest object
  • Assign an onreadystatechanged event handler
  • Execute a request
  • Abort the request before the response has been handled

You will now see that the readystatechange handler will be called,
with the readystate property set to '4'. Any attempt to read the
XmlHttpRequest object properties will fail.

The author mitigates this problem by assigning an abort state to the request when the manual-abort is performed, and detecting it and returning before trying to read any other properties. Though this approach would only really work if you are performing the abort yourself.

A similar problem was documented on the this WebSync Google Groups post. Towards the end of the discussion there is an implication that this problem only occurs

if you've got the standards and IE9 rendering
modes both set

Hope that points you in the right direction.

凉墨 2024-12-09 23:53:31

在readyState==4例程中,包含一个类似于以下内容的try和catch:

try {
    var response=xmlHttp.responseText;
    }
catch(e) {
    var response="Aborted";
}

我们发现这是对上述内容最成功的解决方案。

Within the readyState==4 routine, include a try and catch similar to:

try {
    var response=xmlHttp.responseText;
    }
catch(e) {
    var response="Aborted";
}

We found that this to be the most successful resolution to the above.

吃颗糖壮壮胆 2024-12-09 23:53:31

将 切换

if ((a.responseXML) && (a.readyState==4))

if ((a.readyState==4) && (a.responseXML))

因为顺序很重要。似乎在 IE9 上,如果状态不是 4,responseXML 和 reponseText 在被访问时会产生此错误(我不知道为什么......)

Switch the

if ((a.responseXML) && (a.readyState==4))

to

if ((a.readyState==4) && (a.responseXML))

As the order matters. it seems that on IE9 if the state is not 4, the responseXML and reponseText yield this error if being accessed (I have no clue why...)

余生共白头 2024-12-09 23:53:31

我在我的框架中收到此错误。它只显示在 IE 中(见图)。我简单地将响应包装如下:

if(request.readyState == 4)
{
  // get response
  var response = request.responseText;
}

I was getting this error in my Framework. It only shows up in IE (go figure). I simply wrapped the response like below:

if(request.readyState == 4)
{
  // get response
  var response = request.responseText;
}
不语却知心 2024-12-09 23:53:31

当我过早地读取“status”属性时(在readyState为4/DONE之前),IE9会发生这种情况。

It happens for me with IE9 when I read the "status" property prematurely (before readyState is 4 / DONE).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文