JQuery.get () does not work in Internet Explorer

I have a problem, guess what, IE8. The following code, simplified for clarity, does not work at all:

alert('before get'); $.get(getActivityURL('ActionName',{ ts: new Date().getTime(), ...other params...}), {cache:false;}, function (xml) { alert("in get callback"); },'xml'); // End $.get() alert('in after get'); 

GetActivityUrl () returns a valid URL with request parameters.

This works correctly in FF and Chrome. However, in IE8, this does not even fall into the $ .get () callback. I get warnings "before" and "after", but not a warning "in", and, really, nothing happens, and the request is NOT sent. I really don't know what to think here.

The response headers are "Content-Type: application / xml; charset: iso-8859-1," as confirmed by FF.

EDIT: $ .post () doesn't work either.

+4
source share
5 answers

IE is notorious for caching. Therefore, you need to make sure that you are not getting a cached result.

You can disable caching worldwide by setting the value of the cache property to false in the ajaxStart method.

 $.ajaxSetup({ cache: false }); 

Or If you want to exclude the cached result on a specific ajax call, add a unique number at the end of the URL. You can use the $.now() method to get a unique number

 $.get("someurl.php?" + $.now() ,function(result) { // do something with result }); 

$.now() method returns a number representing the current time.

+12
source

I'm not sure if this is a problem, but try to remove the ";" in {cache: false}

IE does not like any additional material in {}, for example {a: a, b: b, c: c,} will work in FF, but not in IE

+1
source

I think IE has a cache problem.

So add Math.random() , another parameter at the end, for example "&mathRandom="+Math.random(); Because IE will recognize the same request as the previous one, so it will provide data from the cache instead of the shooting request.

+1
source
 $J.get(getActivityURL('ActionName' // End $.get() 

It is right? I mean $ J ... Do you use multiple JS frameworks or something like that?

0
source

tried:

 $.ajax({ url: getActivityURL('ActionName',{ts: new Date().getTime(), ...other params...}), data: data, success: function (xml) { alert("in get callback"); }, dataType: 'xml' }); 

Just guess

EDIT:

I found an interesting thread that can help you, check this out:

JQuery issue in Internet Explorer 8

0
source

Source: https://habr.com/ru/post/1335568/


All Articles