如何捕获错误网:: ERR_ABORTED [英] How to catch error net::ERR_ABORTED
本文介绍了如何捕获错误网:: ERR_ABORTED的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在ajax中捕获错误网:: ERR_ABORTED。这是我的代码
How to catch error net::ERR_ABORTED in ajax. This is my code
$.ajax({
url: "http://example.com",
dataType: "jsonp",
jsonp: "callback",
timeout: 5000,
success: function () {
},
error: function (xhr, textStatus, errorThrown) {
}
})
在控制台中我收到此错误
In console I get this error
jquery.js:9679 GET http://example.com/?callback=jQuery33102519970992725571_1523023091094&_=1523023091095 net :: ERR_ABORTED
我试过尝试抓住
但我不能得到任何错误。我在那里我怎么能抓住这个错误。我也需要跨域访问
。在此先感谢。
I have tried Try catch
but I cannot get any error.is there any way how I can catch this error. I need cross-domain access
too. Thanks in advance.
推荐答案
您可以使用 fail()
作为这样
const request = $.ajax({ //your code })
request.fail((jqXHR, textStatus) => {
console.log(textStatus);
});
这篇关于如何捕获错误网:: ERR_ABORTED的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文