How to send Ajax request on every 1s using JQuery?

后端 未结 5 1476
独厮守ぢ
独厮守ぢ 2021-01-03 06:43

How to send Ajax request on every 1s using JQuery ?

5条回答
  •  离开以前
    2021-01-03 07:30

    The interval 1 sec is small enough and it can be that you will start the second request before you receive response to the first request. So you should either start the next request after receiving of the previous one (see the suggestion of Martin Jespersen) or save jqXHR from the previous $.ajax request in a variable and use it to abort the previous request (see here an example)

提交回复
热议问题