Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
47
rated 0 times [  48] [ 1]  / answers: 1 / hits: 66074  / 10 Years ago, tue, january 20, 2015, 12:00:00

I'm trying to have a custom error handler when something goes wrong (i.e. the server does not respond) on the ajax call for loading new data into my datatable.



$table.DataTable().ajax.url(ajaxURL).load();


By default it shows an alert and I can change that to throw a javascript error with the following setting:



$.fn.dataTable.ext.errMode = 'throw';


But with this, I just have an error logged to the console and I'm not sure how to catch that thrown error so I still can't provide my own error handler.



There is also an error event listed in the documentation, but that doesn't seem to get triggered, so the following never alerts.



$table.on( 'error', function () { alert( 'error' );} );


Everything else I've found so far is for the legacy code, such as setting the fnServerData, which I would like to avoid getting into.



Is there a method to set the ajax error callback in the 1.10 API?


More From » datatables

 Answers
103

New error event handling has been added in Datatables v1.10.5 (released 10th February 2015).



$.fn.dataTable.ext.errMode = function ( settings, helpPage, message ) { 
console.log(message);
};


See docs here:

https://datatables.net/reference/event/error

https://cdn.datatables.net/1.10.5/


[#68151] Friday, January 16, 2015, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
josiah

Total Points: 208
Total Questions: 105
Total Answers: 107

Location: Seychelles
Member since Mon, Jun 28, 2021
3 Years ago
;