Want a javascript function to run every minute, but max 3 times

后端 未结 9 941
终归单人心
终归单人心 2020-12-28 17:43

I have a ajax javascript method that pulls data from a page etc.

I want this process to run on a timed interval, say every minute. But I don\'t want it to loop forev

9条回答
  •  孤城傲影
    2020-12-28 18:01

    var testTimeInt = 3;
    function testTime(){
    
        testTimeInt--;
    
        if(testTimeInt>0)
           setTimeOut("testTime()", 1000);
    
    }
    
    
    setTimeOut("testTime()", 1000);
    

提交回复
热议问题