jQuery的ajax“始终"函数jqXHR对象不存在? [英] jQuery's ajax "always" function jqXHR object doesnt Exists?
问题描述
我有一个处理程序:(jQuery ver = 1.7)
I have a handler : (jQuery ver = 1.7)
返回某物.
我通过ajax调用此处理程序:
Im calling this handler via ajax :
我知道always方法应该获得类似于完整func的对象:
I know that the always method should get an object like the complete func :
complete(jqXHR,textStatus)..........//(jQuery文档)
complete(jqXHR, textStatus) ..........//(jQuery Documentation)
但是 当我尝试提醒时:
obj.readyState or
obj.status or
obj.statusText or
obj.responseText-我得到未定义.
obj.readyState or
obj.status or
obj.statusText or
obj.responseText - I get UNDEFINED.
何时,我写alert(obj)
时会给我'aaa'.
When I write alert(obj)
it gives me 'aaa'.
我需要访问obj.readyState,obj.status等...
为什么我没有得到有效的物品?
Why dont I get a valid object?
我要做的就是检查它是否具有 200 返回码.
All I want is to check it had 200 return code.
我想念什么?
推荐答案
always
回调具有3个参数:数据, textStatus , jqXHR 您正在寻找的是第三个- jqXHR
The always
callback has 3 parameters: data, textStatus, jqXHR what you are looking for is the third one - jqXHR
$(function () {
$.ajax({ type: "POST", url: "TestHandler.ashx", async: false }).always(function (data, textStatus, jqXHR) {
alert(data); // aaa
alert(jqXHR.statusText); // 200
alert(jqXHR.status); // OK
});
});
这篇关于jQuery的ajax“始终"函数jqXHR对象不存在?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!