Abort A Previous Ajax Request In jQuery

When using Ajax there will be changes ,where you will need to cancel the Ajax call. I found Aborting is useful while building a search as you type feature and I would abort the previous search and request a new Ajax search each time they typed a new letter. Since their old word has changed to a new word and therefore new meaning, completing the old request is having no purpose or reason since the new word is an entirely different meaning.

Luckily jQuery has made this almost easy as you can see by my example below.



Now you can type something for each keyup() event it will cancel the previous Ajax request and it will make new request to the sever.That is it, Simple and straightforward isn’t it.

I hope you like this Post, Please feel free to comment below, your suggestion and problems if you face - we are here to solve your problems.


Leave a Reply

Your email address will not be published.