JQuery ajax when a periodic call is called, doesn't work on IE8

I am currently doing the same ajax request using jQuery every 2 seconds. For some reason, it only works on IE8 for the first time. It seems that each subsequent request automatically switches to the onSuccess function with the same result as the first request.

The same code works on FF3 and Chrome.

Does anyone know about this error and how to crack it? Or am I just doing something wrong?

+5
source share
3 answers

IE has a caching function ... it's possible that it just cached your request. Make sure you add something like a random number to the query string, for example:

var url = "/yoururl.html";
url = url + "&random=" + Math.random();
+12
source

, , $.ajax cache, false , , , , . , .

+6

I just ran into the same thing and fixed it by setting the "cache" property of your ajax function call to false.

        $.ajax({
            url: "/ws/inventory/checkavailability/",
            async: false,
            dataType: 'json',
            cache:false,
            success: function (data) {
                //so something interesting
            }, error: function (error) {
                //display error?
            }
        });
0
source

All Articles