在下面的javascript中,我想根据http错误代码来处理错误。可以处理所有其他类型的http错误,但不能处理407,当服务器发送状态为407时,jqXHR.status显示为"0“而不是"407”。你知道为什么它没有显示为407的状态吗?有没有其他方法来处理客户端中的407错误。
function handleError(jqXHR) {
if (jqXHR.status === 500) {
// Server side error
} else if (jqXHR.status === 404) {
// Not found
} else if (jqXHR.status === 407) {
// Proxy Authentication is required
// This is not working, when server send http status code as 407, client side it is recieved as 0
}
}
发布于 2018-03-09 20:20:15
您可以测试jqXHR.readyState并处理“未发送”状态。(参见此处:https://xhr.spec.whatwg.org/#xmlhttprequest )因此,您可以处理“未发送”状态,而不是处理“需要身份验证”状态。
https://stackoverflow.com/questions/49106730
复制相似问题