My JSON output from controller reads like this:
{"subscribers":"[{\"code\":\"Code1\",\"name\":\"Name1\",\"id\":539,\"companyId\":\"CD1\",\"acctNum\":\"Dell\"},{\"code\":\"Code2\",\"name\":\"Name2\",\"id\":540,\"companyId\":\"CD2\",\"acctNum\":\"Dell1\"}]"}
It is the output variable "data" from the controller 'three.htm' :
$("#getName").click(function() {
$.getJSON("three.htm", function(data) {
})
.fail(function( jqxhr, textStatus, error ) {
var err = textStatus + ', ' + error;
alert(err);
console.log( "Request Failed: " + err);
})
.success(function(data){
console.log("loadDataTable >> "+JSON.stringify(data));
loadDataTable(data);
})
});
function loadDataTable(data){
$("#recentSubscribers").dataTable().fnDestroy();
var oTable = $('#recentSubscribers').dataTable({
"aaData" : data,
"processing": true,
"aoColumns" : [
{"mData" : "code" },
{ "mData" : "name" },
{ "mData" : "id" },
{"mData" : "companyId" },
{"mData" : "acctNum" }
]
});
}
However, the datatable isn't showing any results.
Pretty much stuck here after trying many approaches. Help please.