How to reload the DataTables table when executing the function? Function:

function changeStatus(id, st){ $.ajax({ url: '/dcm/list_instructors.php?action=status&id=' + id + '&st=' + st, }); } 

table:

 $(document).ready(function() { console.log($("#status")); var table = $('#instructors').DataTable({ "ajax": "/dcm/list_instructors.php?data=json", "columns": [ {"data": "Actions"}, {"data": "ID"}, {"data": "Name"}, {"data": "Address"}, {"data": "Homephone"}, {"data": "Workphone"}, {"data": "Cellphone"}, {"data": "Status"} ] }); }); 
  • If you are given an exhaustive answer, mark it as correct (a daw opposite the selected answer). - Nicolas Chabanovsky

1 answer 1

Starting from version 1.10.0 like this ( documentation ):

 function changeStatus(id, st) { $.ajax({ url: '/dcm/list_instructors.php?action=status&id=' + id + '&st=' + st, }).done(function() { table.DataTable().ajax.reload(); }); } 

Based on the answer to the question: " How to reload / refresh jQuery dataTable? ".