How to set a timer in javascript

前端 未结 6 914
傲寒
傲寒 2020-12-03 06:21

I want to run the following code:

ajaxUpdate(10);

With a delay of 1 second between each iteration. How can I do this?

6条回答
  •  执念已碎
    2020-12-03 06:37

    You can use the function setTimeout(String fonc, Integer delay). For example, to execute your code each second you can do :

    window.setTimout("ajaxUpate",100);
    

    Hope i answer to your question ;)

提交回复
热议问题