Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

99
Views
Ajax is not aborting when stop button is clicked

I have this code, and when the stop button is clicked, I need to stop the ajax, but for some reason ajax is not aborting.

var started = false;
  $(document).ready(function () {
  $('#start').click(function () {
  var count = $("#names").val();
  var line = count.split("\n");
  started = true;
  line.forEach(function(value, index) {
      setTimeout(
              var ajaxCall = $.ajax({
                  url: url,
                  type: 'GET',
                  data: someData,
                  success: function(result) {
                      //some works here
                   }
              });
                      $('#stop').click(function () {
                      ajaxCall.abort();   //abort Ajax
                      $('#check').attr('disabled', false);
                      $('#stop').attr('disabled', 'disabled');

                  })
          }, 2000 * index);
       });
  });

});

about 4 years ago · Santiago Gelvez
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!