Wienievra Wienievra - 5 months ago 8
jQuery Question

Ajax not firing in IE10

My script works in Chrome. I had some difficulty in Edge and IE10. I have narrowed it down to the script below. After some testing it works in Edge but still not in IE10

JS Library:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script type="text/javascript">


JS

function scrollhandler() {
$.getJSON("check_time_scroll.php", function(update) {
if (update.count===true) {
alert("Update available");
}
});
}
setInterval(scrollhandler, 10000);


Additional Info:
check_time_scroll.php
check if there is any new relevant content in the database. If there is, I get a
true
and if
true
I load content to a
<div>
.

For testing purposes I have replaced the
<div>
loading script with an
alert
.

Is it possible that I am using the wrong Library? In Edge the alert test works but does not upload the content to the
<div>
with the original script.

Original script:

function scrollhandler() {
$.getJSON("check_time_scroll.php", function(update) {
if (update.count===true) {
$("#scrolltext").load('unifoscrolltext.php');
}
});
}
setInterval(scrollhandler, 10000);

Answer

Maybe the IE10 have problem with cache information.

function scrollhandler() {
    var d = new Date();
    var cache = d.getTime();
    $.getJSON("check_time_scroll.php?cache=" + cache, function (update) {
        if (update.count === true) {
            $("#scrolltext").load('unifoscrolltext.php?cache=' + cache);
        }
    }); 
} 

setInterval(scrollhandler, 10000);
Comments