Ajax Heartbeat using setInterval, Preventing multiple calls at the same time

后端 未结 3 1399
不知归路
不知归路 2021-01-01 00:06

I wish to make an AJAX call using jQuery as a \"heartbeat\" in the background so that my web application can check for new data. For example every 10 seconds.

I hav

3条回答
  •  攒了一身酷
    2021-01-01 00:33

    Instead of using setInterval, call setTimeout() in the AJAX completion callback to start each call 10 seconds after the previous one finishes.

提交回复
热议问题