简体   繁体   中英

JQuery $.ajax request not working in IE

I'm using a jquery to make an $.ajax request. It works fine in chrome/firefox and other browsers as far as I know however in IE it works first time then when a second request is made in IE the ajax fails with a 406 non acceptable error.

I've tried setting different accept headers with no luck. Any ideas?

$.ajax({

    type: Request.method,

    url: Request.request_url,

    cache: false,

    data: Request.getVarsString(),

    dataType: "text",

    beforeSend: function(req){
        req.setRequestHeader("Accept", "text/html,application/xhtml+xml/application/xml;q=0.9,*/*;q=0.8"); 
        req.setRequestHeader("Accept-Language", "en-gb,en;q=0.5"); 
        req.setRequestHeader("Accept-Encoding", "gzip, deflate");
        Request.loadBeforeSend(id);
    },

    success: function(replyData){
        Request.requestComplete(id, replyData);
    },

    error: function(jqXHR, textStatus){
        alert(textStatus+" "+jqXHR.status);
        //Request.requestComplete(id, replyData);
    }

}); 

Im using a get method. Request is a static class with some methods and variables that i use to make an Ajax request

The older version of IE don't accept request type like PUT, DELETE, they accept only POST and GET. Maybe your method is not accepted ny IE?

I'm not totally sure why IE was doing it but I have a hashed URL. At the time it was displaying a hash of "#!/querystring" but when I changed it to "#!querystring" it worked fine. I'd be interesting in knowing if anyone knows why IE doesn't like the first example.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM