How to redraw a dataTable with new json data using ajax

How to redraw a dataTable with new json data using ajax

naggappannaggappan Posts: 2Questions: 2Answers: 0
edited June 2014 in Free community support

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

This discussion has been closed.