Populating Datatables with JSON array from GET request
Set dataSrc
to ''
. As the documentation states :
Get JSON data from a file via Ajax, using dataSrc to read data from a plain array rather than an array in an object:
$(document).ready(function() {
$('#example').DataTable({
"processing" : true,
"ajax" : {
"url" : "https://api.myjson.com/bins/14t4g",
dataSrc : ''
},
"columns" : [ {
"data" : "id"
}, {
"data" : "name"
}, {
"data" : "lat"
}, {
"data" : "lon"
}]
});
});
and your code works -> http://jsfiddle.net/nzn5m6vL/