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

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

全局配置以下可实现

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

 

posted @ 2017-04-11 16:54  Vincent-Li  阅读(526)  评论(0编辑  收藏  举报