The setInterval function does not work on I.E. 10. I have a web page that when a form is submitted, it will trigger a long process on the server for downloading a file. I use setInterval to repeatly poll the server for progress so that the user gets some kind of update on the progress.
The ProgressServlet will only get called once only. I did not test this on another web browser because it is "illegal" to use another browser in my company.
<script>
var myVar;
function validateForm()
{
//validation logic omitted
myVar = setInterval(getProgress(), 1000);
return true;
}
function getProgress() {
//ProgressServelt will return progress of the long process on the server
$.get("ProgressServlet", $.now(), function(res) {
if (res != "9999" || res == "No value avaliable") {
$("#progress").html(res);
} else {
$("#progress").html("Stopped: " + res);
clearInterval(myVar);
}
});
}
</script>
<form method="post" action="CreateServlet" name = "create">
Change Number(s):<br>
<input type="text" name="change" id="change">
<p></p>
<input type="submit" value="Download" onClick="return validateForm()">
</form>
<p></p>
<button id="send" name="send">Display</button>
Change
myVar = setInterval(getProgress(), 1000);
to
myVar = setInterval(getProgress, 1000);
That is: pass the function, not what it returns.