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

87
Visualizações
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 à 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