I am trying to implement functionality whereby clicking a button on the screen will cause my jQuery dataTable to refresh (as the server-side data source may have changed since the dataTable was created).
Here's what I have:
$(document).ready(function() {
$("#my-button").click(function() {
$("#my-datatable").dataTable().fnReloadAjax();
});
});
But when I run this, it does nothing. What's the proper way to refresh the dataTable when the button is clicked? Thanks in advance!
You can try the following:
http://www.meadow.se/wordpress/?p=536
With version 1.10.0 of DataTables, it is built-in and easy:
or just
$('#example').DataTable().ajax.reload();
http://datatables.net/reference/api/ajax.reload()
If you use the url attribute, just do
Hopes it helps someone
You could use an extensive API of DataTable to reload it by
ajax.reload()
If you declare your datatable as
DataTable()
(new version) you need:If you declare your datatable as
dataTable()
(old version) you need:I had done something that relates to this... Below is a sample javascript with what you need. There is a demo on this here: http://codersfolder.com/2016/07/crud-with-php-mysqli-bootstrap-datatables-jquery-plugin/
This simple answer worked for me
ref https://datatables.net/forums/discussion/38969/reload-refresh-table-after-event