0

我正在使用 $.ajax() 向我的 java 服务器发送一个发布请求。我知道当我收到这个请求时我的服务器会设置一个cookie,但是cookie没有出现在浏览器中,有谁知道发生了什么以及如何解决它?

4

2 回答 2

0

在设置 cookie 时,您是否仔细检查了这些参数(cookie 的路径、域、到期时间)?

尝试这个:

$.ajax({
    type: 'POST',
    url: myUrl,
    success: function(output, status, xhr) {
     alert(xhr.getResponseHeader("'Set-Cookie'"));
  },
  cache: false
});
于 2013-09-06T20:06:59.917 回答
0

I think my question isn't very clear, it is because I am doing cross domain implementation. The cookies can't set it. I need to add "Access-Control-Allow-Credentials", "Access-Control-Allow-Origin" and "Access-Control-Allow-Headers" on the server response and add xhrFields : {withCredentials : true} in the ajax request.

于 2013-09-10T18:39:05.477 回答