根据带有凭据的请求,Firefox只会发送凭据以及跨域帖子
invocation.withCredentials = "true";
设置...但似乎jQuery的Ajax API没有为此提供任何机制.
有没有我错过的东西?还有其他方法可以做到吗?
似乎已经在stackoverflow上讨论了类似的东西,但我找不到完全相同的东西.
我正在尝试使用CORS(跨源资源共享)发送Cookie,但它无法正常工作.
这是我的代码.
$.ajax(
{
type: "POST",
url: "http://example.com/api/getlist.json",
dataType: 'json',
xhrFields: {
withCredentials: true
},
crossDomain: true,
beforeSend: function(xhr) {
xhr.setRequestHeader("Cookie", "session=xxxyyyzzz");
},
success: function(){
alert('success');
},
error: function (xhr) {
alert(xhr.responseText);
}
}
);
Run Code Online (Sandbox Code Playgroud)
我没有在请求HEADER中看到这个cookie.