自动提示和ajax调用

I am working with the autosuggestion search. The problem is I have a "keyup" event that sends an ajax request to the database on the change of the search query term. From time to time it happens that user quickly changes those search query terms. What I mean by that:

1) User enters "123" -> an ajax request to the database is sent. 2) Right after that, very rapidly, he decides to drop '3' from "123" -> a new ajax request with "12" as a new search query is sent to the database. The second request fetches the data faster than the first one. And this leads to the situation when the search query remains correct, but the list of found products is not as first request with its fetched data rewrites the second one. It should be vice verse.

Please, help me come up with some ideas on how I can, like, synchronize those two request

Kind regards!

查看全部
weixin_33712987
weixin_33712987
2018/06/10 10:12
  • ajax
  • jquery
  • 点赞
  • 收藏
  • 回答
    私信

0个回复