We have a search bar and pagination on the page, using jquery to make ajax request As one start searching for particular record many ajax request is being fired , though we added ajax abort to the previous request but in rails query is still happening for all,
How to stop the rails processing when previous ajax request is aborted
If the Rails server has received the AJAX request,
.abortwill not stop the server from executing it. This stackoverflow answer describes how you could use readyState to check if the last request was completed or not.However, I believe what you're looking for is a debounce function. A debounce function limits the rate at which a function gets fired. You could use that to make sure that the search bar fires a backend request only after certain seconds have passed since it last received an input. That would greatly reduce the number of queries that get sent to the Rails server.