//jQuery的post方法
function scPostExt(url, data, callback, async, type, dataType) {
if (!type) {
type = "post";
}
if (!dataType) {
dataType = "json";
}
if (!async || async == null || typeof (async) == "undefined") {
async = true;
}
$.ajax({
url: globalData.apiUrl + url,
type: type,
dataType: dataType,
data: data,
async: async,
headers: {
'token': '3333333'
},
success: callback,
error: function (xhr, textStatus, errorThrown) {
console.log("進入error---");
console.log("狀態碼:" + xhr.status);
console.log("狀態:" + xhr.readyState); //當前狀態,0-未初始化,1-正在載入,2-已經載入,3-資料進行互動,4-完成。
console.log("錯誤資訊:" + xhr.statusText);
console.log("回傳回應資訊:" + xhr.responseText); //這里是詳細的資訊
console.log("請求狀態:" + textStatus);
console.log(errorThrown);
console.log("請求失敗");
}
});
}
狀態碼:404
狀態:4
錯誤資訊:error
回傳回應資訊:undefined
headers洗掉后能正常請求
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/262741.html
標籤:JavaScript
