IE 8中的AJAX不一致? [英] AJAX inconsistency in IE 8?

查看:109
本文介绍了IE 8中的AJAX不一致?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的代码:(而不是其中的狡猾部分)

This is my code: (rather, the dodgy part thereof)

if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
    var requisicao=new XMLHttpRequest();
} else {
    var requisicao=new ActiveXObject("Microsoft.XMLHTTP");
}

好的.有时这可以正常工作,但有时IE中的Javascript Debugger告诉我这一点:

Ok. Sometimes this works fine, but sometimes the Javascript Debugger in IE tells me this:

对象不支持此属性或方法model.js第59行第3个字符

Object doesn't support this property or method model.js line 59 character 3

相当于…….

var requisicao=new XMLHttpRequest();

让我感到烦恼的是,有时IE 8会接受并继续运行,但有时会窒息而无法正常工作?

What bugs me is the fact that sometimes IE 8 accepts this and moves on but sometimes it chokes and doesn't work?

欢迎任何帮助

预先感谢

推荐答案

编辑:显然,在这种情况下,Internet Explorer的行号是正确的.这似乎是Internet Explorer 8的常见问题.这里有一个潜在的解决方案: Ajax应用程序可在一些浏览器,而不是其他浏览器.

Apparently, in this case, Internet Explorer's line number is correct. This seems to be a common problem with Internet Explorer 8. There's a potential solution here: Ajax app works in some browers, not others.

这是代码的相关部分:

try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); }
catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); }
catch (e) { try { xmlhttp = new XMLHttpRequest(); }
catch (e) { xmlhttp = false; }}}

不幸的是,Internet Explorer的行号并不总是准确的,因为它们基于您自己的代码内部序列化.错误消息可能来自其他行(希望在第59行附近).

我会检查您在某个对象上调用方法的位置,无论出于何种原因,该位置都可以设置为不同的值.

这篇关于IE 8中的AJAX不一致?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆