【问题标题】:Cookie not sent in Chrome Cross Domain PostCookie 未在 Chrome 跨域发布中发送
【发布时间】:2012-08-29 09:48:27
【问题描述】:

我想使用 POST 提供跨域服务。我可以看到 preflight OPTIONS 调用成功,但是当我发布时,cookie 没有在 Chrome 中发送。相同的 javascript 和服务器代码适用于 Firefox 和 Safari。可能是什么问题呢?以下是详细信息:

请求网址:http://j.test.com/Post
请求方法:OPTIONS
状态码:200 OK
请求标头查看源代码
接受:/
接受字符集:ISO-8859-1,utf-8;q=0.7,*;q=0.3
接受编码:gzip、deflate、sdch
接受语言:en-US,en;q=0.8
Access-Control-Request-Headers:origin、x-requested-with、content-type、accept
访问控制请求方法:POST
连接:保持活动
主持人:j.test.com
来源:http://www.amazon.com
参考:http://www.amazon.com/Gone-Girl-A-Novel-ebook/dp/B006LSZECO/ref=pd_rhf_gw_s_ts_2
用户代理:Mozilla/5.0 (Windows NT 5.1) AppleWebKit/536.11 (KHTML, like Gecko) Chrome/20.0.1132.47 Safari/536.11

响应标头
访问控制允许凭据:true
Access-Control-Allow-Headers:origin、x-requested-with、content-type、accept
访问控制允许方法:POST、OPTIONS
访问控制允许来源:http://www.amazon.com
访问控制最大年龄:1728000
连接:保持活动
内容长度:0
日期:格林威治标准时间 2012 年 9 月 4 日星期二 16:44:48
服务器:nginx

我使用 jQuery:

  jQuery.ajax({
     type: "POST",
     url: "http://j.test.com/Post",
     xhrFields: {
        withCredentials: true
     },
     data: {
            referringUrl: document.URL
           },
     success: function(data) {
     },
     error: function (responseData, textStatus, errorThrown) {
     }
  });

【问题讨论】:

  • 你找到问题了吗?

标签: jquery google-chrome cross-domain cors


【解决方案1】:

您的jQuery.ajax() 呼叫中可能还需要crossDomain: true

【讨论】:

    【解决方案2】:

    【讨论】:

      猜你喜欢
      • 2020-12-20
      • 1970-01-01
      • 1970-01-01
      • 2021-03-05
      • 2014-08-02
      • 2013-01-05
      • 1970-01-01
      • 2021-10-06
      • 2012-06-09
      相关资源
      最近更新 更多