I am loading data into tables from the server via ajax. I do so with a call to special functions that return the data I need.. OR a detailed error if there is some problem. I then want to show the error to the user, in a nice format. All of the above was easily achieved with the code at the bottom.. However, I still get a warning displayed by dataTables itself, saying: "DataTables warning: table id=MFF_YouDontFollow - [Object Object]" (in the scenario that the server response is of an "error" json structure). Now, this is despite the fact that the actual data returned by the handling function is actually valid. The warning from dataTables seems be unrelated to the actual data returned by the dataSrc function. Even when I return actual real "fake" data, which DOES get shown properly in the table, the warning is displayed. Seems like the warning with regards to the fact that the ORIGINAL data is not valid, rather than the data returned by dataSrc.
Am I doing it wrong? Is there a better way to handle such a scenario when the response is either "data" or "warning" structure?
Here's the code I use:
dataSrc : function ( json ) {
if (json.error) //Indicates that the returned result is an error
{
//My nice error notification
$.smallBoxCountdown({
title : "Attention!",
content : json.error.message,
color : "#C46A69",
iconSmall : "fa fa-2x fa-warning bounce animated",
timeout : 15*1000,
});
//Returning empty
return [];
}
else
{return json.data;}