JQuery DataTables - AJAX Reloading Not Working?

OTable is a local variable reference to the datatable that is not valid outside the document ready function.

OTable is a local variable reference to the datatable that is not valid outside the document ready function. Do this instead: $('#click_me'). Click( function () { $('.

Admin_users').dataTable().fnReloadAjax(); } ).

Got this error: DataTables warning: Cannot reinitialise DataTable. To retrieve the DataTables object for this table, please pass either no arguments to the dataTable() function, or set bRetrieve to true. Alternatively, to destory the old table and create a new one, set bDestroy to true (note that a lot of changes to the configuration can be made through the API which is usually much faster).

– James ckman Nov 7 at 21:56 Are you sure you're not passing any parameters in the dataTable() call in the click() function? That seems to be the gist of the error message. In any event, I use this same technique without trouble — my initialization of the table is somewhat different (paginate, processing, and state_save are all false), however.

– Larry Lustig Nov 7 at 22:02 yeah I copied your code exactly. Tried placing it in both the $(document). Ready block as well as outside that block.No luck.

– James ckman Nov 7 at 22:07 Well, you can try specifying { bRetrieve: True } as the message suggests. – Larry Lustig Nov 7 at 22:08 Also, I assume you've linked the script with fnReloadAjax in it.It's not part of the base implementation of dataTables. – Larry Lustig Nov 7 at 22:14.

Scope issues are always tricky. I'm not claiming to be an expert, but this way seems to work fairly consistently for me: Create a new object in the global scope. All other functions and variables specific to my application reside in this object.

The technique is simply namespacing via an object Ensure sane ordering of scripts: first jQuery, then any other 3rd-party plugins, then application script(s); call the document ready function (if it is being used) only at the end of all that. Example of creating a namespace with an object: var myApp = myApp || {}; // create it if the variable isn't already being used myApp. OTable = $('#admin_users').

DataTable({ parameters }); myApp. SomeUtilityFunction = function(foo) { alert(foo) }; As an aside, you can see that I'm using an ID for my dataTable in the above example. A selector is a selector, so yours will work, but it's always going to be a unique table anyhow, so the ID selector is a bit more efficient.

I'm also not 100% sure if dataTable() only operates on the first node returned by the selector or not (I hope so! ), which is a potential issue. With that in place, you could bind your click in the document ready without fear: $(function() { $('#click_me').

Click( function () { myApp.oTable.fnReloadAjax(); // if script is available }); }); As an additional aside, if #click_me is ever in danger of being destroyed (for example, being inside the table that's being redrawn! ) you would be better off using .delegate() (jQuery 1.6. X) or .on() (1.7 and beyond).

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions