Reloading the entire table via ajax
Reloading the entire table via ajax
I'm building an admin tool in WordPress and on the backend I'm loading the default table successfully with DataTables.
I then have these filter options that make an ajax call and return an entirely new html table with the filtered data.
[code]
$.get(ajaxurl, save_scope, function(response) {
table.html(response);
$('.return-table').DataTable();
});
[/code]
DataTable() isn't rendering on the newly loaded table. Am I doing this right? Do I have to go back and re-work my ajax call to return a JSON object or something? I'm not that fluent with js.
I then have these filter options that make an ajax call and return an entirely new html table with the filtered data.
[code]
$.get(ajaxurl, save_scope, function(response) {
table.html(response);
$('.return-table').DataTable();
});
[/code]
DataTable() isn't rendering on the newly loaded table. Am I doing this right? Do I have to go back and re-work my ajax call to return a JSON object or something? I'm not that fluent with js.
This discussion has been closed.
Replies
Failing that, please link to a test case showing the issue.
Allan
[quote]object is not a function[/quote]
in jquery.dataTables.js on line 4713
On first load, I'm just loading a table and having dataTables run on it, no problem. Then I have a filter button and I altered my code to return a JSON array which outputs:
[code][["","Post","","","Last Verified","Piwik Visits"]][/code]
I'm trying this for starters as they are my headers.
I'm directly inserting this ajax response in the fnReloadAjax:
[code]
$.get(ajaxurl, save_scope, function(response) {
table.DataTable().fnReloadAjax(response);
});
[/code]
I'm probably not seeing this right...hm
Allan