Reputation: 1781
According to this question, we use deboucing to make a live search like facebook
But here is my case, when I set the timeout as 300ms, first I type query A and wait for 300ms then an ajax request is triggered, but when waiting for server to response for query A, I do another query B, and after 300ms, the response for query A finally shows up, and then immediately response for query B shows up too, so you see 2 results flashing, how to prevent this? (cancel the first request or something?)
Upvotes: 0
Views: 427
Reputation: 8849
Depending on how many results you return I see 2 possible actions:
The first method will only work well when the first request returns more items than are displayed.
Upvotes: 1