I've encountered a peculiar issue with my XMLHttpRequest and JSON file. While I can successfully access the data, it seems to only iterate through 32 child objects within each parent object.
Take, for example, this snippet from the routes.json file:
{
"Routes": [
{
"name": "Route 1",
"locations": [
{
"Name": "ABC Store",
"Address": "123 W 456 S"
},
{
"Name": "XYZ Store",
"Address": "321 E 654 N"
},
{
... (66 other locations)
}
]
},
{
... (more routes)
}
]
}
My main index.php file calls this data using an XMLHttpRequest. However, when looping through the locations of each route, it stops at 32 iterations. Here's a snippet of the code:
var request = new XMLHttpRequest();
request.open("GET", "routes.json", false);
request.send(null);
var route_data = JSON.parse(request.responseText);
var allRoutes = route_data.Routes;
for (var key1 in allRoutes) {
var locations = allRoutes[key1].locations;
for (var key2 in locations) {
//I forgot to put this line in, and it was causing the problem
if (!allRoutes.hasOwnProperty(key2)) continue;
// Repeat the Route Name for each location to get a count
console.log("Route Name: "+allRoutes[key1].Name);
// Repeats only 32 times max when there are really 66+ in most of them
}
}
Does JavaScript impose a limit on the number of iterations when looping through arrays or objects retrieved via XMLHttpRequest?