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

76
Views
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
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!