我搜索过高低,但是甚至没有提到它.使用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