From what I gather normally with Jsons and Datatables, datatables will load each record as a row of data for your table.
I am trying to find a good way to load json data as columns instead of rows using DataTables. But I haven't been seen a good method to accomplish this. Here is the code I have currently which loads rows:
$(document).ready(function() {
var table = $('#jsontable').dataTable(); //Initialize the datatable
$('#load').on('click',function(){
var user = $(this).attr('id');
if(user != '')
{
$.ajax({
url: 'process.php?method=fetchdata',
dataType: 'json',
success: function(s){
console.log(s);
oTable.fnClearTable();
for(var i = 0; i < s.length; i++) {
table.fnAddData([
s[i][0],
s[i][1],
s[i][2],
s[i][3],
s[i][4]
]);
} // End For
},
error: function(e){
console.log(e.responseText);
}
});
}
});
});