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

78
Vistas
Want to populate datatable row one by one using asynchronous in JavaScript

I am facing a problem where I want to return all the rows one by one without interupting the current function. The issue is intermittent. Sometimes I can get all the datatables data but sometimes not.

Then I started investigating and realised after checking the developer tool in network section that it throws error after page 10. And the error is 429 too many requests. Also, realised that the script was synchronous json call.

429 too many requests

I tried using below code in my script but the spin is not working. Also, found that this is not recommended way.

Can someone help me with solution? Thank you

 // Set the global configs to synchronous 
            $.ajaxSetup({
                async: false
            });

My Script

function getMed(sDate, eDate) {
     var pData;    
    var firstURL = mUrl + "?sDate=" + moment(sDate).format(dateFormat) + "&eDate=" + moment(eDate).add(1, 'day').format(dateFormat) + "&pNum=1";
   ....
    }).done(function (data) {
       
        if (pData.Number > 0) {          
            var counter = 0;
           // Set the global configs to synchronous 
            $.ajaxSetup({
                async: false
            });

            var requestsProcessed = 0;
            for (var i = 1; i <= pData.Number; i++) {
                $("#iconSpin").css('display', 'block');   
                
                var pURL = mUrl + "?sDate=" + moment(sDate).format(dateFormat) + "&eDate=" + moment(eDate).add(1, 'day').format(dateFormat) + "&pNum=" + i;
                console.log("calling: " + pURL);
                var pageRequest = $.getJSON(pURL, function (data) {

                    requestsProcessed++;
                    $("#progress").innerHTML = "Fetching batch " + requestsProcessed + " of " + pData.Number + " batches.";
                   ....

                }).fail(function () {                   
                    $("#iconSpin").css('display', 'none');                   
                    console.log("fail for " + pURL + " in " + new Date());
                });
                console.log("completed for " + pURL + " in " + new Date());

            }
        } else {
            alert("There is no data.");
           
        }

    }).fail(function () {     
    
        $("#iconSpin").css('display', 'none');      
    });
}
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