I have an array from php and here it is
$results = array(
"sEcho" => 1,
"iTotalRecords" => count($newdata),
"iTotalDisplayRecords" => count($newdata),
"aaData" => $newdata
);
echo json_encode($results, JSON_PRETTY_PRINT);
all of the data is also packed as array inside aaData my question here is how can I get that data? my target is to populate that in a table and here is my code.
<script>
var i,x;
var tb = $("#col_details");
$(document).ready(function() {
$.ajax({
url: 'qry_collection.php',
type: "POST",
datatype: 'json',
success: function(data) {
/* Delete table content */
data = JSON.parse(data);
console.log(data);
$("#col_details tr").remove();
/* Populate the table */
for (i = 0; i < data.length; i++) {
var tr = $("<tr />");
for (x in data[i]) {
var td = $("<td />");
td.html(data[i][x]);
tr.append(td);
count = i
}
tb.append(tr);
}
}
});
});
</script>
I can see the array using the console but populating it as table is my prob.
TYSM
here is the image from console

$resultsvariable from an AJAX POST. You'd need toechoout$resultsonqry_collection.php.for (var i=0; i<data.aaData.length; i++) { console.log(data.aaData[i]); }