$.ajax({
type:"POST",
dataType:"json",
url:webLoginOut(),
data:{},
beforeSend: function (XMLHttpRequest) {
XMLHttpRequest.setRequestHeader("X-Auth0-Token", getToken("token"));
},
success:function(res){
if(res.code === 0){
window.location.href = "/jsp/user/login/login.html";
removeSessionStorage("token");
return;
}
$.kyAlert(res.msg,1000);
removeSessionStorage("token");
setTimeout(location.replace(location.href),2000);
},
error:function () {
$.kyAlert("網絡出錯啦,請稍後再試試!",1000,"danger");
}
})
主要添加:
beforeSend: function (XMLHttpRequest) {
XMLHttpRequest.setRequestHeader("X-Auth0-Token", getToken("token"));
},