Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

72
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda