Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8033817
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T01:49:14+00:00 2026-06-05T01:49:14+00:00

I have 2 javascript loops, one nested in the other, that does an AJAX

  • 0

I have 2 javascript loops, one nested in the other, that does an AJAX call to the serverside. The loops generate a pair of numbers (latlng coordinates), which is then passed to the server via .getJSON() where it will be inserted into a MySQL table.

Problem: The script runs for about 6 minute, with a total of 13200 AJAX calls. In chrome’s webdeveloper tools, it says 5656/13646 requests 536.20KB/2.15MB. When I check the tables for the inserted entries, I only see 5655 rows! What happened to the rest?

JS Code

for(var i = 0; i < 110; i++) {
    var lat_current = lat_start + lat_increment * i;

    for(var j = 0; j < 120; j++) {

        // Do some calculations
        // More code here...

        // Insert LatLng into database
        $.getJSON(base_url + 'insert_latlng_to_crawl', 
            {
                lat: lat_current,
                lng: lng_current
            }, 
            function(json){
            });

    }

}   
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T01:49:15+00:00Added an answer on June 5, 2026 at 1:49 am

    You should create a javascript object, then pass it to the server and process it server-side

     var coords=Array();//Create an array to store the calculations
     for(var i = 0; i < 110; i++) {
        var lat_current = lat_start + lat_increment * i;
    
        for(var j = 0; j < 120; j++) {
    
        // Do some calculations
        // More code here...
    
        // append the results to the array
        coords.push({lat: lat_current, lng: lng_current});
    
    
    }
    
    //Make the ajax call to the server, sending the completed Array JSON encoded
    coords= JSON.stringify(coords);
    $.ajax({
      type: 'POST',//you should send big chunks of data via POST
      url: url,
      data: coords,
      success: success,
      dataType: JSON
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have code that looks something like this in javascript: forloop { //async call,
I have a three-step process that is entirely reliant upon JavaScript and Ajax to
In one HTML page I have a JavaScript function checkUpdates() that hits the server.
I have a javascript loop and want to highlight some numbers for(i=0;i<=100;i++){ $(#mydiv).append(<span>+i+</span>); }
Here is the situation. I have some javascript that looks like this: function onSubmit()
We have received some JavaScript from an agency that looks wrong, but works. For
It looks like JavaScript does not have access to authentication cookies ('ASP.NET_SessionId', '.ASPXFORMSAUTH') in
I have Javascript that opens another window and registers a click handler for all
I have JavaScript that is doing activity periodically. When the user is not looking
I have a nested for loop inside a for loop that is supposed to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.