I have defined another function in jQuery to get some data from the database and put the database data into the existing DataTable.
My Code:
for(var i=0; i< result.length; i++) { $('#DataTable tbody tr').append([result[i]['id'],result[i]['name'],result[i]['contact'], result[i]['status']] ); }
I have tried with this code to add some data into the existing DataTable. But it does not work properly. How can I append data into the existing DataTable in jQuery?
If you want to append data into the existing DataTable, apply this code.
var table = $('#DataTable').DataTable(); table.clear().draw(); for(var i=0; i< result.length; i++) { table.row.add([result[i]['id'],result[i]['name'],result[i]['contact'], result[i]['status']] ).draw( false ); } table.draw();
Question and answer is powered by AnsPress.io