When using jquery.DataTables I run into the following problem consistently when trying to redraw the table from an AJAX source, but it also occurs with any of the API methods I attempt to use.
I am using version 1.10.
Example
var table = $('#table').dataTable( {
initComplete: function(settings, json) {
....
},
ajax: 'url',
serverSide: true,
order: [[2, 'desc']],
stateSave: true,
language: {
"lengthMenu": "Display _MENU_ records per page",
"zeroRecords": "Nothing Found",
"infoEmpty": "Nothing Found",
"infoFiltered": "(filtered from _MAX_ total records)"
},
lengthMenu: [[10, 25, 50, -1], [10, 25, 50, "All"]],
pageLength: 10,
lengthChange: true,
ordering: true,
paging: true,
processing: false,
searching: true
});
setInterval(function(){
table
.dataTable()
.order( [[ 2, 'asc' ]] )
.draw( false );
}, 30000);
Error
Uncaught TypeError: Object [object Object] has no method 'order'
This is a copy of the example posted in the DT site, which the exception of the DT in the example passing additional parameters upon initialization.
I know the error is due to the table object not having the methods from .dataTable(), but other then that I am not sure how to get it working so that it does the draw(false), or any other API method.
The part that gets me is that a,
table.fnDraw();
Works perfectly fine....
Thank you for the help in advance.