var host="http://"; // var token = localStorage.getItem("token"); var token = "tokenTest"; $.ajaxSetup({ type: "post", contentType: "application/json", dataType: "json", headers: { "token": token } // xhrFields: { // withCredentials: true // }, // complete: function(xhr) { // //token过期,则跳转到登录页面 // if(xhr.responseJSON.code == 401){ // parent.location.href = baseURL + 'login.html'; // } // } });