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

64
Views
Ajax Call Request every 5 Seconds And Wait Before Sending The Request Until The Previous Request Is sent

I want to send ajax Request every 5 seconds And each request waits until the previous request is sent successfully , This is my code it works but it sends requests even if the previous request was not sent successfully.

Here My Code :

$(document).ready(function() {
  $('#myform').on('submit', function(e) {
    e.preventDefault();
    $("#sending").show();
    $("#send").attr('disabled', true);
    $("#send").attr('value', "Sending ...");

    var ajax_call = function() {

      $.ajax({
        url: "fbshr.php",
        type: "POST",
        data: {
          postURL: $('#postURL').val()
        },
        success: function(data) {
          $(data).appendTo($("#response")).before("");
          $('#response').animate({
            scrollTop: $('#response').prop("scrollHeight")
          }, 500);
          $("#num-msg-1").html($('#response p.alert-success').length);
          $("#num-msg-2").html($('#response p.alert-danger').length);

        }
      });
    };

    var interval = 5000;

    setInterval(ajax_call, interval);
  });
});
about 4 years ago · Juan Pablo Isaza
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!