Each row in the data table has a delete button.
On click of the delete button, I am calling this code:
$('.deleteButton').live('click', function () {
var $this = $(this);
var url = $this.attr("id");
$("#example").fnReloadAjax();
$.getJSON(url, Success());
});
The url is action of the controller that takes the Id and deletes the data from the database. That works.
I now want to call the refresh/redraw function of datatable so it can load new results but it doesn’t work.
Datatable is:
$("#example").dataTable({
"aoColumns": [
{ "sTitle": "Id" },
{ "sTitle": "Name" }],
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": '@Url.Action("FetchData", "Home")',
"sPaginationType": "full_numbers",
});
Can anyone please advice?
Quoted from the API datatable page – on the
fnReloadAjax()bullet:Thus, you’d probably better use
fnDraw.[EDIT] Actually, the order of your calls should be: