use*_*394 16 javascript ajax jquery
如何使用jquery捕获500错误消息?我想继续检查500错误消息,直到它发生变化,并在50秒后超时.
我使用下面的代码尝试捕获并检查500错误消息但它似乎没有捕获500错误消息.我可以在萤火虫中看到它
$.ajax({
statusCode: {
500: function() {
alert(" 500 data still loading");
console.log('500 ');
}
}
});
Run Code Online (Sandbox Code Playgroud)
Vic*_*ary 10
尽管@Danny提到了已接受的答案,但您也可以在较新版本的jQuery中执行此操作.
var xhr = $.ajax({
url: "somewhere"
});
xhr.fail(function(xhr, textStatus, error) {
// Error handling stuff here ...
});
Run Code Online (Sandbox Code Playgroud)
请参阅延迟对象.
是否缺少url在$.ajax类似下面
$.ajax({
url: "/path to page",
statusCode: {
500: function() {
alert(" 500 data still loading");
console.log('500 ');
}
}
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
17533 次 |
| 最近记录: |