Run a JavaScript function continuously repeating with a time interval

前端 未结 5 1688
南方客
南方客 2021-02-06 15:31

This is my first question, and I would appreciate you answering soon.

I would like code to repeat a function continuously... I have tried some code but it hasn\'t worked

5条回答
  •  庸人自扰
    2021-02-06 16:29

    This will repeat the task until you clear the interval (with clearTimeout(repater))

    var repeater;
    
    function doWork() {
     $('#more').load('exp1.php');
     repeater = setTimeout(doWork, 1000);
    }
    
    doWork();
    

    Per OP's original condition:

    I want code that repeat function continuously...

提交回复
热议问题