0

I use Ajax to check data and show it on the page, and I use varnish cache. The data is displayed on all browsers, except on IE 11, until I deactivate the varnish cache.

function checkMyData() {
var surl = 'index.php?eID=thismydata';
if (navigator.userAgent.indexOf('MSIE') !== -1 || navigator.appVersion.indexOf('Trident/') > 0) {
    surl += '&hash=' + Math.random();
}
$.ajax({
    type: "GET",
    url: siteurl + surl,
    asynchronous: true,
    data: 'mode=datalist' +
            '&initdatalist=' + initdatalist +
            '&datastr=' + datastr,      
    success: function (answer) {
        var response;
        try {
            response = eval('(' + answer + ')');
        } catch (err) {
            alert('Err: ' + answer);
            return;
        }
        if (initdatalist == 1)
            initdatalist = 0;
        $basic_cont = '<div class="row"><div class="col-md-6 col-md-offset-3"><p class="data-title">' + 
                response.firstmatch + response.otherdata + '</p></div></div>' +
                response.matches;

        $("#thisdaydata").empty();
        $($basic_cont).appendTo("#thisdaydata");
    }
});
}

HTML Output for all browsers (except IE 11) :

<div id="thisdaydata">
<div class="row">
   <div class="col-md-6 col-md-offset-3">
       <p class="data-title">data here</span></p>
   </div>
</div>

HTML Output for IE 11 :

<div id="thisdaydata"></div>

is this ajax not compatible with IE 11 ?

user17092013
  • 11
  • 1
  • 9

1 Answers1

0

IE will automatically cache responses from GET requests while other browsers will let you decide if you’d like to cache the result or not. Once IE has successfully made a GET request, it will no longer even make that AJAX call until the cache expires on that object. You can add cache : false value in your ajax. For more details and methods you can refer to this article and this question.

Yu Zhou
  • 11,532
  • 1
  • 8
  • 22