简体   繁体   中英

setInterval on IE10

The setInterval function does not work on IE 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM