Bri*_*ian 7 javascript jquery jquery-post jquery-mobile
我有一个用于向服务器发送请求的包装函数,如果服务器返回401的代码,我需要做一些特定的事情,我不知道如何获取这些数据
$.mobile.showPageLoadingMsg();
$.post(apiUrl+method,p,function(d) {
$.mobile.hidePageLoadingMsg();
console.log(d.success);
console.log(d.message);
if(d.success == true){
window[callback](d.data);
}
else{
if(d.message != null){
alert(d.message);
}
}
},'json')
.error(function() {
//need to check for 401 status here to do something
$.mobile.hidePageLoadingMsg();
alert("error");
});
Run Code Online (Sandbox Code Playgroud)
如果我的服务器端代码抛出一个401异常,jquery .error函数选择它只是因为它不是200 OK但我需要检查它是否是401代码.
| 归档时间: |
|
| 查看次数: |
5682 次 |
| 最近记录: |