Jquery Ajax CORS + HttpOnly Cookie

后端 未结 1 1154
悲&欢浪女
悲&欢浪女 2021-02-05 14:34

I have got CORS working on my current project, although one thing I cannot seem to get working correctly is the cookies.

Now I get the cookie fine, the server issues it

相关标签:
1条回答
  • 2021-02-05 15:25

    Try using the beforeSend property instead of xhrFields. In your case:

    var ajaxOptions = {
        url: serviceResourceUrl,
        type: "get",
        dataType: "json",
        success: successCallback,
        error: failedCallback,
        beforeSend: function(xhr){
          xhr.withCredentials = true;
        }
    };
    
    $.ajax(ajaxOptions);
    

    You can learn more here: Sending credentials with cross-domain posts?

    0 讨论(0)
提交回复
热议问题