ajax option getting real error information
ajax option getting real error information
Hi
for serverside errors (like 500) i want to get the REAL error info.
I am using $('#' + htmlTableId).on('error.dt', function (e, settings, techNote, message) {
$('#message').html('An error occurred:' + "<br/>" + message);
});
which technically works correctly, but the message is the general DataTables warning.
Serverside I am generating a 500 and returning a Json {"error":"real error information on server"}
Can this be displayed via the above error function?
Or has one to do the ajax getting data separately (which is no problem at all per se and then setting the data) so I can get this info there. Meaning: the ajax option does not allow to get the real serverside generated error info?
Anybody knows? Thanks for clarifying.
Cheers, Michael
This question has an accepted answers - jump to answer
Answers
Actually, I don't think there is... This is the relevant bit of code in DataTables core and it doesn't pass the xhr object to the error logging function.
However, there is the
xhr
event that you could use. You could listen for that and check to see if the third parameter passed in isnull
, if so then it is an error and you can get the string returned by the server from the fourth parameter (and use$.parseJSON
to convert it into JSON).Allan
thanks a lot for that very prompt answer. clarifies situations an options for implementing that. wondering that that is no general concern. but can live ok with it.
One other option to solve that is, to place the complete standard ajax call in a separate function that is called then via the callback feature "ajax": function (data, callback, settings)......
This style of implementation should allow also for serverside "scrolling" with the scroller and get the complete original error. (Not yet tested myself)
Michael