How to change error message in lightbox upon Ajax submission error?
How to change error message in lightbox upon Ajax submission error?
Hi folks,
Simple question: for Datatables Editor used with the lightbox, if there's an HTTP error code in the response, Datatables will simply show an error message saying to contact the system administrator. If, however, I would like to show a custom error message based on the HTTP error code, it doesn't seem possible. Am I missing something? Please note that I could change the message text via the internationalization options but I want to be able to post multiple custom error messages and not just one global one. Here's a snippet of my code:
///...
if (jqxhr.responseText.includes("Unable to login with provided credentials.")) {
editor.error('Identifiants incorrects. Veuillez réessayer.');
}
errorCallback(jqxhr, textStatus, errorThrown);
//...
This question has an accepted answers - jump to answer
Answers
Listen for the
submitError
event and callerror()
inside that. Thexhr
object is passed in as the second parameter tosubmitError
so you can inspect that for the status code.Allan
Great, thanks! Here's what I ended up doing: