Datatables is a useful tool for listing data. It is obviously necessary to modify the table content on the fly. Sometimes we need to add more rows and sometimes need to clear the table. New rows can be added to a DataTable very easily using the fnAddData method. Simply call the function with the data that is to be used for the new row (be it an array or object). Multiple rows can be added using the method while you run this inside a loop.
In order to refresh the table and add newly retrieve rows to the datatable, we need to clear the table first. fnClearTable function will clear all the rows from the table.
While the table is clear then it is ready to add newly arrived rows to the table with the function fnAddData.