Optimised search using Ajax and keypress

前端 未结 4 1234
南方客
南方客 2021-01-30 02:35

I have the following code that I want to use to search a database as a user is typing into a textbox. The code below works fine but it seems a little inefficient, as if a user i

4条回答
  •  情深已故
    2021-01-30 03:07

    I just want to add some more points to the question. Throttling and debounce concepts are related to this topics.

    Throttling : It will make you to execute the function in a specified interval.

    Debounce : It will make you to execute the function when user has stopped typing.

    You can achieve this two by setimeout , cleartimeout functions.Check this link will give you a clear walk-through of it.

    LINK

提交回复
热议问题