Trying to add delay to jQuery AJAX request

后端 未结 3 1802
余生分开走
余生分开走 2021-02-06 08:28

I am trying to delay an AJAX request so that it is sent out 2-3 seconds after the LAST keyup of an input cell.
So far I have managed to delay the requests, but after 2-3 sec

3条回答
  •  抹茶落季
    2021-02-06 09:14

    What you are trying to do is called debouncing.

    Here's a jquery plugin by Ben Alman that does the job.

    And underscore.js includes this functionality as well.

    There's really no need to hack the ajax request system. Just make sure it's called at the right moment.

提交回复
热议问题