How to Abort Ajax requests using jQuery

0 votes

Using jQuery, how can I cancel/abort an Ajax request that I have not yet received the response from?

Apr 27, 2020 in Java-Script by kartik
• 37,510 points

edited Apr 27, 2020 by kartik 9,100 views

1 answer to this question.

0 votes

Hello kartik,

Just use ajax.abort().

For example you could abort any pending ajax request before sending another one like this

//check for existing ajax request
if(ajax){ 
 ajax.abort();
 }
//then you make another ajax request
$.ajax(
 //your code here
  );

Hope this is helpful!!
Thank You!!

answered Apr 27, 2020 by Niroj
• 82,880 points

Related Questions In Java-Script

0 votes
1 answer

How to send data in request body with a GET when using jQuery $.ajax()?

Hello @kartik, Sending the data in your scenario,I ...READ MORE

answered Jun 18, 2020 in Java-Script by Niroj
• 82,880 points
18,636 views
0 votes
1 answer

How to manage a redirect request after a jQuery Ajax call?

Hii kartik, You can resolved this issue like ...READ MORE

answered Apr 27, 2020 in Java-Script by Niroj
• 82,880 points
28,601 views
0 votes
1 answer

How to select and manipulate CSS pseudo-elements such as ::before and ::after using jQuery?

Hii @kartik, Here is the way to access ...READ MORE

answered May 18, 2020 in Java-Script by Niroj
• 82,880 points
6,293 views
0 votes
1 answer

How to manage a redirect request after a jQuery Ajax call?

Hii, You can solved this issue by: Adding a ...