При использовании datatables Мне нужно использовать пользовательскую ajax-функцию.
Канонический пример, найденный здесь, выглядит следующим образом:
$('#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 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 an actual error?
callback(err);
}
} );
Тем не менее, я не вижу способа сообщить datatables, что произошла ошибка ajax.
Как это сделать?