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 ;-)
精彩评论