【发布时间】:2015-04-17 20:20:38
【问题描述】:
有没有办法抓到failed to load resource: net::ERR_CONNECTION_REFUSED,我试过了:
try {
$.post('',{},function(res) {
}).fail(function (xhr, textStatus, errorThrown) {
xhr.textStatus = textStatus;
xhr.errorThrown = errorThrown;
console.log('fail',xhr);
// how to get the 'ERR_CONNECTION_REFUSED' or anything else as string?
});
} catch(e) {
console.log('catch',e);
}
fail 函数可以捕获,但我没有得到有关错误的信息,要么是:
- ERR_NAME_NOT_RESOLVED
- ERR_CONNECTION_REFUSED
- ERR_BLOCKED_BY_CLIENT
- ERR_TUNNEL_CONNECTION_FAILED(使用代理时)
或其他任何东西.. 问题是,如何得到那种错误?
【问题讨论】:
-
您不会有意获取有关错误的具体信息(因为否则可能会被滥用以深入了解用户的内部网络)。
标签: javascript jquery ajax exception