How to replace error message and prevent upload?
How to replace error message and prevent upload?

Currently I’m allowing the user to upload a JSON file which is then translated into the datatable below it. However, if the user attempts to upload a file without the proper data, it will display a datatables error pointing it out and it will still send the data to the datatables.
My question is two parts: 1) how do I replace the system error with something more front end friendly, and 2) how do I prevent a file that triggers such an error from being sent to the datatable?
This question has an accepted answers - jump to answer
Answers
You can handle errors using the
error
event and$.fn.dataTable.ext.errMode
.Not sure if there is a way to do this. Possibly a global variable used as an error flag could be used. Inside
initComplete
you can check the flag and clear the table if needed. There may be better ways but I built an example to show this:http://live.datatables.net/pinavuki/1/edit
Kevin
Awesome - I ended up just using the error event as you specified for now to remove the error. Thanks as usual Kevin!