Here’s the code:
$.ajax({
url:"http://.....pullEntireDBPopulation.php",
cache:false,
datatype:"json",
success:function(popData){
alert("Population size: " + popData.length);
popProducers = new Array();
for(i=0;i<popData.length;i++){
popProducers[i] = popData[i].ProducerName;
}
});
}
I’ve written the .PHP to pull every piece of data from a database, which I’ve checked on the browser, so I know it’s not that. Still, every time I run the page, it says the array is around 5000 long even though that’s larger than the entire database. What’s going on???
If it helps, it’s also saying that when I write the data into arrays, they are undefined in the array. So there’s clearly a problem with the data being read into the page since I know it works on it’s own, but I can’t figure it out.
I found the problem.
datatype: "json"apparently doesn’t render the same asdataType: "json"I hate when it’s stupid things like this! Because it wasn’t reading it as a JSON due to my capitalization error, it was just reading in a string rather than an array of objects–> problem.