I have a getJSON function that looks like below:
$.getJSON("jsonStats.php?action=segment", function(json) {
//Loop over each of the values in the jSON response to make the table.
var tableSegments = '',
counter = 1;
$.each(json, function(key, value) {
tableSegments += '<tr>';
tableSegments += '<td></td>';
tableSegments += '<td>'+counter+'</td>';
tableSegments += '<td>'+value['name']+'</td>';
tableSegments += '<td>'+value['y']+'</td>';
tableSegments += '</tr>';
counter++;
});
$('#segmentTable').empty().append(tableSegments);
});
The issue that I am running into is that its running the each statement/creating the table before it even gets the data. Is there a way to make it wait until it actually has the jSON data before doing that part?