相关疑难解决方法(0)

使用跨域帖子发送凭据?

根据带有凭据的请求,Firefox只会发送凭据以及跨域帖子

invocation.withCredentials = "true";

设置...但似乎jQuery的Ajax API没有为此提供任何机制.

有没有我错过的东西?还有其他方法可以做到吗?

javascript jquery cross-domain

76
推荐指数
2
解决办法
14万
查看次数

跨域POST请求不发送cookie Ajax Jquery

似乎已经在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.

javascript cookies ajax jquery cross-domain

59
推荐指数
4
解决办法
9万
查看次数

标签 统计

cross-domain ×2

javascript ×2

jquery ×2

ajax ×1

cookies ×1