Editor data error handling
Editor data error handling
From the https://editor.datatables.net/reference/event/submitError documentation for the submitError event, the description states:
"This is fired when data has been submitted to the server but an error occurred on the server, not a validation in data error, but an error in the processing of the data (typically a JSON formatting error)."
The documentation states this event is not for validation in data error, but there is no reference to which event should be used for validation in data error. None of the other supplied events seem to fit the need either.
This question has an accepted answers - jump to answer
Answers
Do you want an event that will be triggered when the server returns an error in the JSON? If so, use
postSubmit
, which gives you access to the JSON returned and you can take whatever action you required.Regards,
Allan
Yes, that is what I'm looking for. I'll try postSubmit instead. Thank you.
Actually, postSubmit doesn't seem to do what I need. The error info is sent back as json, but the form still tries to "submit" itself normally which causes the form submission to "hang" (the progress indicator shows and the JS errors out).
I tried to stop the event with preventDefault, stopPropagation and returning false from the function, but nothing stops the submission from occurring.
Well, in the end I found that I can return JSON that contains an error and fieldErrors field that contains the data errors. I can't find any reference to this in the documentation.
The server JSON return information is documented here.
postSubmit
will indeed happen after the form as submitted itself to the server. There is apreSubmit
event if you want to inspect the data before it is sent to the server and that is cancellable.Allan