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 8,715 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,069 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,197 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,049 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 ...READ MORE

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

What is meant by passing the variable by value and reference in PHP?

Hello, When the variable is passed as value ...READ MORE

answered Mar 27, 2020 in PHP by Niroj
• 82,880 points
2,942 views
0 votes
1 answer

Connection with MySQL server using PHP. How can we do that?

Hey @kartik, You have to provide MySQL hostname, ...READ MORE

answered Mar 27, 2020 in PHP by Niroj
• 82,880 points
993 views
0 votes
1 answer

How to retrieve or obtain data from the MySQL database using PHP?

Hello kartik,  Actually there are many functions that  ...READ MORE

answered Mar 27, 2020 in PHP by Niroj
• 82,880 points
3,007 views
0 votes
1 answer

What are the differences between mysqli_connect and mysqli_pconnect?

Hello, mysqli_pconnect() function is used for making a persistence ...READ MORE

answered Mar 27, 2020 in PHP by Niroj
• 82,880 points
3,318 views
0 votes
1 answer

How can I Abort Ajax requests using jQuery?

Hello @kartik, It is always best practice to ...READ MORE

answered Jun 18, 2020 in Java-Script by Niroj
• 82,880 points
2,554 views
0 votes
3 answers
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP