I am integrating jquery datatable to my project. When call is made to service, some how following error is error thrown
cannot read property 'assorting' of undefined
Here is the code
Timeline
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="js/jquery.dataTables.js"></script>
<body>
<script>
$(document).ready( function() {
$('#example').dataTable( {
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "URL",
"fnServerData": function ( sSource, aoData, fnCallback, oSettings ) {
console.log(aoData);
oSettings.jqXHR = $.ajax( {
"dataType": 'json',
"type": "POST",
"url": sSource,
"data": aoData,
"success": fnCallback
} );
}
} );
} );
</script>
<div id="dvContent">
<table cellpadding="0" cellspacing="0" border="0" id="example">
</table>
</div>
</body>
Here is the Sample out put of the server
{"some":"yyy", "open":null, "program":1, "more":"must", "comment":000 }
Your table needs a THEAD section and a TBODY section:
<table cellpadding="0" cellspacing="0" border="0" id="example">
<thead><tr><th>First Column</th><th>Second Column etc.</th></tr></thead>
<tbody>
</tbody>
</table>
Note: it's also important that your THEAD not be empty as dataTable requires you to specify the number of columns of the expected data as specified by <tr><th></th></tr>
In addition to the point by @bumptious above, it's important to note that the THEAD section cannot be blank; dataTables requires the <tr><th>column1</th></tr>
content as placeholder within the table.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With