开发者

jQuery xhr object properties in ajax function callbacks

开发者 https://www.devze.com 2023-01-29 15:57 出处:网络
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?

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

精彩评论

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