"Silent error" on Ajax sourced data
"Silent error" on Ajax sourced data
Hi,
When using Ajax sourced data with a dataSrc defition, is there a way to achieve deal corrupted data ?
For example, if you define your dataSrc attribut as "results.resultSet" and that variable (data.results.resultSet) does not exist, the ajax data cannot be processed correctly, but I'd like for the table to just show the table as if it had zero results, instead of staying in an inconsistent state (it's throwing an error in the _fnAjaxUpdateDraw function because variable data will be null).
One way to solve the problem is to set the dataSrc as a function and the process it, but i'd like to use the string notation already implemented in the Datatables. I'm duplicatting the fetchData function to see if the data actually exists, if not I'm just returning []. But that way, besides code duplication, we're doing twice the same process of getting the data.
Is there a prettier solution ?