A very simple webpage, it has an empty div in it:
<div id="joblist">
</div>
<script type="text/javascript">
readJobList();
</script>
And the javascript:
function handleReadJobList(text) {
var e = document.getElementById("joblist");
e.innerHTML = text;
setTimeout(function(){readJobList();}, 1000);
}
function readJobList() {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (xhttp.readyState == 4 && xhttp.status == 200) {
handleReadJobList(xhttp.responseText);
}
}
xhttp.open("GET", "joblist.ajax", true);
xhttp.send();
}
When the browser loads the page, readJobList will be called for first time, it sends a HTTP request. handleReadJobList will read the response text, update the content of div, and use setTimeout to call readJobList after one second. This is a cycle, although it's asynchronous.
This code works well on Firefox, Chrome and Opera. But on IE11 it doesn't work. I don't know why. The content of the div only updated one time. It will not be updated anymore.
How to fix it ?