1. 程式人生 > >ajax全域性報錯處理

ajax全域性報錯處理

$(document).ajaxError(function (e, xhr) {
setTimeout(function () {
if (xhr.status === 401) {
window.location.reload();
}
else if (xhr.status === 410) {
$(".web-loading").fadeOut(800);
$("#NoAccessModal").modal();
}
else if (xhr.status === 404){
window.location.href = “/Home/Error404”;
}
else if (xhr.status === 429) {
window.location.href = “/Home/RobortLike”;
}
else if (xhr.status === 408 || xhr.status === 0 || xhr.status === 200 || xhr.status === 501) {

}
else {
window.location.href = “/Home/Error”

  • (xhr.getResponseHeader(“Gbi-Churin-Debugger-Mode”) ? “?previousContextId=” + xhr.getResponseHeader(“Gbi-Churin-HttpContext-Id”) : “”);
    }
    }, 0);

});