Add fnOnParserError function

Add fnOnParserError function

brunoborgesbrunoborges Posts: 2Questions: 0Answers: 0
edited March 2012 in Feature requests
When there's an error parsing data, we want to be able to decide what to do, instead of displaying an alert.

Here is my suggestion to be applied to default fnServerData

[code]
"error": function (xhr, error, thrown) {
if ( error == "parsererror" ) {
if (typeof oSettings.oInit.fnOnParserError === 'function') {
oSettings.oInit.fnOnParserError(error, thrown);
} else {
alert( "DataTables warning: JSON data from server could not be parsed. "+
"This is caused by a JSON formatting error." );
}
}
}

[/code]

Also, theese lines must be added too:

[code]
DataTable.models.oSettings = {
/**
* Function to be called when there's a parsererror.
* @type functinon
*/
"fnOnParserError": null,

(...)
[/code]

[code]
// Map the initialisation options onto the settings object
(...)
_fnMap( oSettings, oInit, "fnOnParserError" );
[/code]

Is DataTables on github? I could fork from there, and do a pull request

Replies

  • brunoborgesbrunoborges Posts: 2Questions: 0Answers: 0
    So I did the pull request on GitHub, here it is:

    https://github.com/DataTables/DataTables/pull/55

    The commit can be seen here:

    https://github.com/brunoborges/DataTables/commit/5a6ccc4a3a24274387f65c9b79873320b424131f
This discussion has been closed.