开发者

jQuery xhr object properties in ajax function callbacks

given an ajax callback like for example...

function showResponse(responseText, statusText, xhr) { }

How can I get a status/reponse code or something from the xhr object?

alert(xhr);              // [object]
alert(xhr.status);       /开发者_开发技巧/ undefined
alert(xhr.statusText);   // undefined


You could use dojo framework and then output the xhr object with

console.dir(xhr)

Otherwise you could print all elements from xhr object with a for each loop

for (var n in xhr) {
  alert(n + " => " + xhr[n]);
}

Note that i dont try this code so the code could include a bug ;-)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜