Ajax CORS iframe,cookie未设置

时间:2014-07-17 04:33:58

标签: javascript jquery ajax cookies

我有一个iframe,src设置为(比方说)domainA.com,父网址为domainB.com,从此iframe我对domainA.com/ajax.asp进行ajax调用,这个适用于chrome和firefox,但不适用于safari和IE。下面是对chrome和safari的完整标题请求。

请求标题(Chrome)

POST /Ajax.asp HTTP/1.1
Host: domainA.com
Connection: keep-alive
Content-Length: 29
Accept: */*
Origin: http://test.takeoutmenuz.com
X-Requested-With: XMLHttpRequest
User-Agent: Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.152 Safari/537.36
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
Referer: http://domainA.com/menu.asp?userid=1025
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8,id;q=0.6
Cookie: userid=1025; ASPSESSIONIDAQCQASBD=IDGHMLJDBHOKJFBIKMCNDHDA; ZZZZZ=here

请求标题(Safari)

POST /Ajax.asp HTTP/1.1
Host: domainA.com
Connection: keep-alive
Content-Length: 29
Accept: */*
Origin: http://test.takeoutmenuz.com
X-Requested-With: XMLHttpRequest
User-Agent: Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.152 Safari/537.36
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
Referer: http://domainA.com/menu.asp?userid=1025
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8,id;q=0.6

如您所见,Safari中没有Cookie标头,根据this page的解释,问题是Cookie内容(如果我没记错的话)。如何让它在没有Cookie的情况下工作,我应该在Ajax.asp中的响应头上执行某些操作,还是在ajax脚本中执行某些操作(我已经在其中添加了withCredential字段)?

0 个答案:

没有答案