jQuery throttling and queuing of AJAX requests

后端 未结 5 1625
庸人自扰
庸人自扰 2021-01-04 11:42

I\'m interacting with an API that allows one action per 5 seconds. However, I want to ensure all requests end up with the host. How can I queue and throttle the requests tha

5条回答
  •  温柔的废话
    2021-01-04 12:10

    If you want to ensure anything then you'd best get a medium other than the internet - it is inherently unreliable. Anyway, in order to try to ensure, you could use the Javascript setTimeout method to initiate the call at a later time.

    Other than that, if you don't want to use any other third party resources, you could look into the delay method exposed by jQuery.

提交回复
热议问题