问题
I've defined my datatable like so:
$('div#accessorial-list-table table').dataTable({
'bProcessing': true,
'bServerSide': true,
'bSort': true,
'sAjaxSource': '/accessorials/fetch',
'sPaginationType': 'full_numbers',
"sDom": '<"top"<"clear">>r',
'aaSorting': [[ 0, 'asc' ]],
'iDisplayLength': 1000,
'oLanguage': {
'sInfoFiltered': '',
'sProcessing': 'DOING THINGS',
'sLengthMenu': '',
'oPaginate': {
'sPrevious': '',
'sNext': '',
'sFirst': '',
'sLast': ''
}
},
"aoColumns": [
null,
null,
null,
{ 'sClass': 'align_center' },
{ 'sClass': 'align_center' },
{ 'sClass': 'align_center' },
{ 'sClass': 'align_center' }
]
});
And my responses look like this:
{
"sEcho": true,
"iTotalRecords": 97,
"iTotalDisplayRecords": 97,
"aaData": [bunch of data]
}
The first fetch works fine, and all of the data loads into the table. However, when I try to sort any of the columns, "DOING THINGS" never goes away even though I see the network request completed successfully in the network inspector. The data that comes back in Ajax is correct both times.
Has anyone seen it do this before or know if my definition of datatables is wrong?
I've run the responses through jsonlint.com and both are valid JSON responses.
回答1:
"sEcho": true,
At the end of the day, the server needs to return what datatables sends in sEcho.
来源:https://stackoverflow.com/questions/18191697/datatables-not-refreshing-after-second-network-request