您的位置:首页 > Web前端 > JQuery

jquery的ajax全局配置

2017-11-23 10:33 190 查看

 jquery的ajax全局配置

var token = localStorage.getItem("token");

$.ajaxSetup({
dataType: "json",
cache: false,
headers: {
"token": token
},
xhrFields: {
withCredentials: true
},
complete: function(xhr) {
//token过期,则跳转到登录页面
if(xhr.responseJSON.code == 401){
parent.location.href = baseURL + 'login.html';
}
}
});


jqgrid全局配置

var token = localStorage.getItem("token");

$.extend($.jgrid.defaults, {
ajaxGridOptions : {
headers: {
"token": token
}
}
});
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: