开发者

Remove cookie from XMLHttpRequest object

开发者 https://www.devze.com 2023-01-04 23:44 出处:网络
I am making an ajax call with jquery like: $.ajax({ url: \"path/to/webservice.asmx\" beforeSend: function(xmlHTTPRequest) {

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 
   }
}

What I would like to do in the beforeSend function is take the incoming xmlHTTPRequest variable tha开发者_如何学编程t 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


Try

xmlHTTPRequest.setRequestHeader("Cookie", "");

EDIT: It appears this does not work, at least not consistently. Read Cookie Monster For XMLHttpRequest

You could also use the jQuery cookie plugin to delete cookies.

$.cookie("nameOfCookie", null);
0

精彩评论

暂无评论...
验证码 换一张
取 消