$ .ajax statusCode [英] $.ajax statusCode
本文介绍了$ .ajax statusCode的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的代码有问题.这是其中的一部分:
I have a problem in my code . This is part of it:
function checkIfAvailable(username){
var url = "/checkAvail?user="+username;
var ans = $.ajax({
url: url,
type: "GET",
context: document.body,
statusCode: {
404: function() {
console.log("-1-1-1-1 WE GOT 404!");
},
200: function() {
console.log("-1-1-1-1 WE GOT 404!");
}
}
});
}
我认为response.status是200,但是我没有输入"200"部分.那么如何打印我得到的response.status?
I think the response.status is 200, but I don't enter the '200' part. So how can I print the response.status I'm getting?
推荐答案
success(data, textStatus, jqXHR){
var statusCode = jqXHR.status;
var statusText = jqXHR.statusText;
}
这篇关于$ .ajax statusCode的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文