How can i prevent DT from drawing after ajax.reload()?
How can i prevent DT from drawing after ajax.reload()?
TheFreeman
Posts: 4Questions: 1Answers: 0
Hi,
i´m using DataTables 1.10.12 for my project.
There the data is loaded by ajax and should be reloaded by interval.
My Problem is, that, if the server sends no fresh data, i cannot prevent DT from go forther after ajax.reload().
setInterval( function()
{
var url = global_datatable_ajax_url + "?version=" + global_datatable_version;
table.ajax.url(url);
table.ajax.reload(function(json){/* THIS DOES NOTHING */}, false);
}, 10000 );
I tried the ajax.reload() with a callback. But it is not fired and DT tries to proccess the loaded data.
Can you help me to manage that issue?
best regards.
This discussion has been closed.
Answers
You can't. If the server returns no data, there is no data for the table to display .
What you would need to do is make your own Ajax call to get the data, then use
clear()
androws.add()
to first clear out the old data and then add the new rows. You could add a logic check around that to check that there is actually data to display.Allan
:-) No, the server returns Data, but there is no table-data.
Because i check on the server, if the data ´has changed.
If not, there is no data to send.
Is there no way to use the DT api to solve the porblem?
Why is the reload-callback not fired?
No - you need to make your own Ajax call and use the API methods I mentioned above if the server doesn't return any data to be displayed in the table. Its just three or four lines rather than a single API call .
It should be: example.
Allan
Hi Allan.
Thank you so much for your great support.
I made me a proper solution with an extern call:
That works for me
Perfect - nice one!
Allan