I've made an AJAX call to my database using
$.post('getdata.php', {passLong: passLong, passLat: passLat},
function(output){
output holds the JSON which was encoded in getdata.php. I'm trying to cycle through the JSON
$.each(output, function(){
console.log(this.CarParkName);
});
In the console I just get 'undefined'. The jQuery each method is supposed to cycle through the JSON and plot markers on a map, the code worked when I had my PHP in the same file, but since using AJAX to get the data from the database, it doesn't work.
I've tried a few different things with the loop, but can't find out what's wrong.
{ "1" : { "CarParkName" : ".." }, "2" : { ...} }then I see nothing wrong with that. If it returns a single object containing an actual array like{ "data": [{"CarParkName" : ".."}, {...}] }then you need to iterate over "output.data" but I don't think "each" is your problem.