Session失效后所有Ajax请求跳转登录地址

当登录的Session失效后,采用ajax请求数据时会没有反应,这时候应该自动跳转到登录页面,让用户重新登录。

全局配置以下可实现

$(function() {        
                $.ajaxSetup({
                    complete:function(XMLHttpRequest,textStatus){
                          if(textStatus=="parsererror"){
                              window.location.href = '../login.html';
                          } else if(textStatus=="error"){
                              
                          }
                    }
                });
}
原文地址:https://www.cnblogs.com/lyxy/p/6694292.html