Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

66
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda