使用xhrFields时的状态代码= 0:{withCredentials:true}在使用Firefox的jQuery $ ajax调用中
我正在使用
xhrFields : { withCredentials: true }
在jQuery $ ajax调用中,以便在我的查询中发送会话cookie。
该调用在我的apache日志上给出了正确的状态代码(401/200取决于是否设置了cookie),但Firefox总是收到状态= 0(即$ .ajax()中的错误)如果我删除了这个xhrFields部分,状态代码没问题(但不发送cookie)
这是我在Firefox中使用xhrFields设置收到的响应对象:
{"readyState":0,"responseText":"","status":0,"statusText":"error"}
我的Apache配置启用了CORS,并且还允许Access-Control-Allow-Credentials(这里是相应的HTTP头)
Access-Control-Allow-Credentials: true Access-Control-Allow-Origin: *
在AJAX调用或webserver配置中是否缺少某些东西?
注意:这在Chrome中运行得非常好
您可能必须比*更明确地指定Access-Control-Allow-Origin标头。
https://developer.mozilla.org/En/HTTP_access_control#Requests_with_credentials说:
重要说明:在响应凭证请求时,服务器必须指定域,并且不能使用通配符。