我正在使用中央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