Override/change DataTables warning message

Override/change DataTables warning message

Mr. FlibbleMr. Flibble Posts: 4Questions: 0Answers: 0
edited September 2010 in General
Is there a 'proper' way to override the "DataTables warning: JSON data from server failed to load or be parsed. This is most likely to be caused by a JSON formatting error." message, or am I best off editing the datatable source code?

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    The best way is to simply pass it valid JSON :-) http://jsonlint.com can be used to check that JSON is valid.

    Another option is to set the variable $.fn.dataTableExt.sErrMode to 'throw', which will cause DataTables to throw a JS error, rather than showing an alert when this error occurs (set the variable before you initialise the table).

    Allan
  • Mr. FlibbleMr. Flibble Posts: 4Questions: 0Answers: 0
    Thanks Allan. I'm trying to handle when the user gets disconnected. My table auto updates and at the moment whenever a disconnect occurs the user gets that message as no JSON is returned. The $.fn.dataTableExt.sErrMode setting will be useful.
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Good error handling - I like it :-). Nice one.

    Allan
This discussion has been closed.