ie8 ajax 对象不支持此属性或方法,javascript – 为什么$.post()上的IE8错误[“对象不支持此属性或方法”]?...

我搜索过高低,但是甚至没有提到它.使用jQuery 1.4.4(没有其他库),到目前为止只发生在Internet Explorer 8上.错误是“对象不支持此属性或方法”,它指向的行位于$.post下面(.

JS

HTML是无与伦比的,所以我只想发布JS.

$(window).load(function(){

$("input[type='submit']", ".scope").live("click", function(e){

e.preventDefault();

// some intervening code defining variables used below...

//only var which is at all complex

var inputs = $form.find(":input").serializeArray();

$.post(

action,

inputs,

function(data){

var $json = $.parseJSON(data);

if ( $json.success == true ) {

if ( testVar == 2 ) {

if ( $json.tabkill == true ) {

killTab(tabID);

} else {

loadPane(rID,tabID,"refreshTop");

}

} else {

loadPane(rID,tabID);

}

} else {

//modal dialogue error message, excised

}

}

).ajaxError(function(e, xhr, settings, exception) {

if (settings.url == action) {

alert("Problem calling: "+settings.url+"\n code: "+xhr.status+"\n exception: "+exception);

}

});

return false;

});

//end window load block

});

解决方法:

问题在于您的行ajaxError.

问题是$.post返回XMLHTTPRequest对象,而不是jQuery选择.必须在jQuery选择上调用ajaxError.

有两种安全的方法:

1)升级到jQuery 1.5.这将引入一个新的XMLHTTPRequest包装器对象jqXHR.您可以按照尝试的方式使用错误处理程序:

$.post(

action,

inputs,

function(data){

/* ... */

}

).error(function(){

alert ("Problem calling: " + action + "\nCode: " + this.status + "\nException: " + this.statusText);

});

2)使用直接调用$.ajax并设置错误处理程序:

$.ajax({

url: action,

data: inputs,

success: function(data){

/* ... */

},

error: function(xhr, textStatus, error) {

alert("Problem calling: " + action + "\nCode: " + xhr.status + "\nException: " + textStatus);

}

});

标签:jquery,javascript,internet-explorer,internet-explorer-8

来源: https://codeday.me/bug/20190715/1471751.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值