首页 > 技术文章 > Session失效后所有Ajax请求跳转登录地址

lyxy 2017-04-11 16:54 原文

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

全局配置以下可实现

$(function() {        
                $.ajaxSetup({
                    complete:function(XMLHttpRequest,textStatus){
                          if(textStatus=="parsererror"){
                              window.location.href = '../login.html';
                          } else if(textStatus=="error"){
                              
                          }
                    }
                });
}

 

推荐阅读