似乎已經在stackoverflow上討論過類似的東西,但我找不到完全相同的東西。跨域POST請求不發送cookie Ajax jquery
我想發送與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);
}
}
);
我在請求標題中看不到這個cookie。
http://stackoverflow.com/questions/3342140/cross-domain-cookies –