I am using DataTables to display some data. When a new record is added (via AJAX), I am trying to reload the table on success. I get the error "oTable is not defined" whenever I try to call either oTable.fnDraw() or oTable.fnReloadAjax(). What am I doing wrong?
I have tried both fnDraw() and fnReloadAjax() and both return the same error.
$(document).ready(function(){
var oTable = $('.admin_users').dataTable({
"bProcessing": true,
"sAjaxSource": 'sql/admin_users.php',
"aaSorting": [[ 0, "asc" ]],
"bJQueryUI": true,
"sPaginationType": "full_numbers",
// "sAjaxSource": 'SQL/dataTable.php',
"bStateSave": true, //Use a cookie to save current display of items
"aoColumns": [
null,
null,
null,
null,
{ "sType": "date", "sClass":"center" }
],
"bScrollCollapse": true,
"sScrollX": "100%"
});
oTable.fnAdjustColumnSizing();
Manual Re-Draw Button:
$('#click_me').click( function () {
oTable.fnDraw();
//oTables.fnReloadAjax();
});