這個方法你要全局設置
//jquery全局配置
$.ajaxSetup({
cache: false,
crossDomain: true,
headers :{'Authorization':token},
complete: function (xhr) {
console.log(xhr)
if(xhr.responseJSON&&xhr.responseJSON.status==401) {
console.log(xhr.responseJSON);
layer.alert('權限不足,請重新登陸', {
icon: 5,
title: "提示"
},function() {
window.parent.location.reload(); //刷新父頁面
window.parent.location.href="./index.html";
});
}
}
});
效果
點擊確定后跳轉到登陸頁
