How to redraw a dataTable with new json data using ajax
How to redraw a dataTable with new json data using ajax
![naggappan](https://secure.gravatar.com/avatar/c35e33b26e394ff01a1cfbf7b9d47024/?default=https%3A%2F%2Fvanillicon.com%2Fc35e33b26e394ff01a1cfbf7b9d47024_200.png&rating=g&size=120)
Here is my code below,
function datatotable(proj_id)
{
proj_id = proj_id || null; // make default value as empty when called from document.ready and page loads
$('#Proj_emp_table').dataTable({
"sAjaxSource": "/projects/project_json/"+proj_id,
oDataTable.fnDraw(),
"fnServerData": function ( sSource, aoData, fnCallback, oSettings ) {
oSettings.jqXHR = $.ajax( {
"dataType": 'json',
"type": "GET",
"url": sSource,
"data": aoData,
"success": fnCallback
} );
}
});
}
Here when a value is changed in select html box i call datatotable function again with new project ID. But it works only one time . 2nd time it gives error stating
"To retrieve the DataTables object for this table, pass no arguments or see the docs for bRetrieve and bDestroy."
How can i reinitialize the DataTable.
I even tried to add,
"bRetrieve": true,
"bDestroy": true,
but still same issue