While using datatables I need to use a custom ajax-function.
The canonical example as found here is as follows:
$('#example').dataTable( {
"ajax": function (data, callback, settings) {
//some async processing happening here
//In the end call the callback.
//However, this callback only accepts a success state
// instead of the usual cb(err, resp) signature.
//This raises the question how to let Datatables know there's an error.
const err = new Error("some contrived error");
//This doesn't work, datatables doesn't signal an actual error
//which can be surfaced to the client. Instead it complains
//the response doesn't have a 'data'-object which it needs
//to correctly create the table. In other words, datatables
//thinks that the passed err-object is an actual correct response.
//Question: so how to actually let datatables know there's an actual error?
callback(err);
}
} );
However, I don't see a way to let datatables know that an ajax-error occurred.
How to do this?