【发布时间】:2011-01-20 04:16:09
【问题描述】:
我正在尝试使用 XMLHttpRequest 在 XSS 请求中设置 Cookie。
我找到了XMLHttpRequest Specification,第 4.6.2-5 节似乎确实建议不允许设置 Cookie、Cookie2 和其他一些标头,但我希望有一个解决方法。
我的 (jQuery) 代码如下,但结果查询失败,因为未设置 cookie。
$.ajax( {
type : "POST",
url : URL,
data: SOAP_INBOX_MAIL_QUERY,
dataType : "xml",
async: false,
beforeSend : function(xhr) {
var cookie = credentials["COOKIE"];
console.info( "adding cookie: "+ cookie );
xhr.setRequestHeader('Cookie', cookie);
},
success : function(data, textStatus, xmLHttpRequest){
},
error : function(xhr, ajaxOptions, thrownError) {
credentials = null;
}
});
【问题讨论】:
标签: javascript jquery ajax jqxhr