[英]jQuery doesn't seem to recognize a different string with an Ajax call statuscode 403
我遇到了一個有趣的情況,我不確定這是我的錯還是jQuery的錯,因此我想向大家咨詢。
當前,我正在執行Ajax調用,該調用返回403狀態代碼。 但是403附帶的字符串與標准不同。
它返回403 access denied
但是根據規范它應該是403 Forbidden
。
我知道如何從服務器獲取200狀態代碼,問題更多在如何處理這種情況。
這是我的Ajax jQuery代碼,在任何console.log()
情況下都不會得到。
this.get = function(){
var callUrl = self.url + "&limit=" + self.limit + "&page=" + self.page;
callUrl += self.getFilterQuery();
callUrl += "&callback=?";
console.log(callUrl);
$.ajax({
url: callUrl,
dataType: 'json',
success: function(response){
console.log(response);
},
statusCode: {
403: function(response){
console.log('error');
console.log(response);
}
},
error: function(response){
console.log(response);
}
});
}
注意:URL是正確的,我可以獲得200狀態代碼,但是我想處理403 access denied
。 我該如何解決?
看起來此調用實際上不是使用XHR請求而是通過JSONP進行的。 (您的網址中的“ callback =?”)-對於JSONP請求,狀態代碼信息不可用。 您將需要確保始終發送有效的響應。
參考此內容以查看是否可以確定特定的拒絕。 http://en.wikipedia.org/wiki/HTTP_403檢查引發錯誤的目錄的設置。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.