似乎已经在 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);
      }
    }
);
我在请求 HEADER 中没有看到这个 cookie。