我正在使用中央ajax函數向服務器發送ajax Post請求。這是函數的代碼:JQuery的Ajax函數在Chrome中工作,但在Firefox中返回404
function postJson(url, jsObj, whenSuccess, whenError){
$.ajax({
type: "post",
headers: {
"Accept": "application/json, text/javascript, */*; q=0.01",
"Content-Type": "application/json, text/javascript, */*; q=0.01"
},
dataType: "json",
url: url,
data: JSON.stringify(jsObj),
success: function(result){
if(whenSuccess !== undefined){ whenSuccess(result); }
},
error: function(xhr){
if(whenError !== undefined){ whenError(xhr.status); }
}
});
}
當我嘗試運行我的應用程序工作在鉻罰款,但在Firefox它拋出一個404我的REST服務助手返回404時,接受或內容類型ISN 「T設置爲JSON ...所以我認爲Firefox的可能不添加標題,但是當我看到所發送的請求:
Request URL:
http://localhost:9081/api/1/localize/validation.json
Request Method:
POST
Status Code:
HTTP/1.1 404 Not Found
Request Headers
08:40:10.000
X-Requested-With:XMLHttpRequestUser-Agent......
Referer:http://localhost:9081/kportal/
Pragma:no-cacheHost:localhost:9081
Content-Type:application/json, text/javascript; charset=UTF-8, */*; q=0.01
Content-Length:2
Connection:keep-alive
Cache-Control:no-cache
Accept-Language:en-US,en;q=0.5
Accept-Encoding:gzip, deflate
Accept:application/json, text/javascript, */*; q=0.01
你可以看到必要的標頭設置。儘管如此,我仍然在Firefox中獲得404,但不是在Chrome中。
有什麼想法?
刪除'然後headers'檢查。 –
如果我刪除頭文件,它也會在chrome中失敗? – Arninja
你在製作一個跨域AJAX請求嗎? – Checksum