The jquery datatables are not loading the data
The jquery datatables are not loading the data

Hi everyone, first of all this plugin is great. But I am having this one issue, I am trying to fetch reports but the values do not load in the datatable. I have done a print_r on the function I am trying to load in the datatable. Kindly note I am using Codeigniter. I will post the function I am printing. If anything else is required that I may help kindly let me know.
On print_r($this->report_m->getReport()); I get the following:
{"sEcho":0,"iTotalRecords":1,"iTotalDisplayRecords":1,"aaData":[["2016-05-08",my.n","0001","sun1234","My Product Name","SUN4321","16.95","5.95","CHEQUE","Telephone"]],"sColumns":""}
On other datatables I had done. The sColumns gives the column names but here it is blank. Can anybody help me as to how to get this to work?
I will include the datatables code to to verify where I have gone wrong.
<script type="text/javascript">
$(document).ready(function() {
var oTable = $('#big_table').dataTable( {
"aoColumnDefs": [
{ "sWidth": "10.5%", "aTargets": [ 9 ] }
],
"bProcessing": false,
"aaSorting": [[0,'desc']],
"bServerSide": true,
"sAjaxSource": '<?php echo base_url(); ?>index.php/agent/report/list_report',
"bJQueryUI": true,
"sPaginationType": "full_numbers",
"iDisplayStart ":25,
"oLanguage": {
"sProcessing": "<img src='<?php echo base_url(); ?>img/ajax-loader.gif'>"
},
"fnInitComplete": function() {
//oTable.fnAdjustColumnSizing();
},
"fnRowCallback": function( nRow, aData, iDisplayIndex ) {
nRow.className = aData[9];
},
'fnServerData': function(sSource, aoData, fnCallback)
{
debugger;
$.ajax
({
'dataType': 'json',
'type' : 'POST',
'url' : sSource,
'data' : aoData,
'success' : fnCallback
});
}
} )
} );
</script>
Answers
sEcho
should never be zero. That suggests that server-side processing hasn't been fully implemented in your server-side script (note you are referring to the legacy documentation for parameters such assEcho
.Allan
Any Idea how to get
"sEcho":1,
? Because In another table, in fact for which I followed the exact same code, On printing the response I get the same -"sEcho":0,
and it works perfectly.sEcho
is a parameter sent to the server by DataTables when it requests the data. As the legacy manual says:Which means that your
<?php echo base_url(); ?>index.php/agent/report/list_report
script is not correctly seeing the request from the client-side and returning the required data.Allan
Hello Sir,
The data is now loading, although this is the same
sEcho:0
andsColumns:":"
The data not loading was my fault. I was calling the wrong function in the<?php echo base_url(); ?>index.php/agent/report/list_report
I thank you for your interest. I guess I need some more knowledge to fully understand the working of this wonder you have created.