从XMLHttpRequest对象中删除Cookie
问题描述:
我使用jquery进行ajax调用:
I am making an ajax call with jquery like:
$.ajax({
url: "path/to/webservice.asmx"
beforeSend: function(xmlHTTPRequest) {
//modify headers here
//remove cookies
}
success: function() {
//do stuff
}
}
喜欢做在beforeSend函数是接收xmlHTTPRequest变量设置和修改标头删除cookie对象,在那里,所以在调用我的web服务,它不更新表单认证在asp.net
What I would like to do in the beforeSend function is take the incoming xmlHTTPRequest variable that is set and modify the headers to remove the cookie object that is in there, so in the call to my web service, it does not renew forms authentication in asp.net
答
尝试
xmlHTTPRequest.setRequestHeader("Cookie", "");
EDIT:似乎无效,至少不一致。请阅读 Cookie Monster For XMLHttpRequest
It appears this does not work, at least not consistently. Read Cookie Monster For XMLHttpRequest
您还可以使用 jQuery Cookie插件删除Cookie。
You could also use the jQuery cookie plugin to delete cookies.
$.cookie("nameOfCookie", null);