DataTables 1.10.25 does not report server-side error messages

DataTables 1.10.25 does not report server-side error messages

aklietzaklietz Posts: 8Questions: 0Answers: 0

Link to test case: http://live.datatables.net/muxavuxi/1/edit

Error messages shown: Instead of displaying the server error response { error: 'The SQL password is incorrect' } DataTables instead throws an uncaught exception.

Description of problem:

Bug 1: Instead of displaying the error response from the server 'The SQL password is incorrect', DataTables triggers an uncaught exception in the console log Error: Script error. (Line 0) The error.dt event does not fire. No output is shown to the user.

This is due to the following uncaught exception:

jQuery.Deferred exception: TypeError: Cannot read property 'length' of undefined
at _fnAjaxUpdateDraw (datatables.js:14539:27)
at datatables.js:14389:5
at callback datatables.js:14282

Bug 2: Because of the uncaught exception, the Processing... box is never dismissed.

Replies

  • allanallan Posts: 63,572Questions: 1Answers: 10,482 Site admin

    Add data: [] to the JSON return: http://live.datatables.net/muxavuxi/3/edit .

    DataTables currently needs the data property, even if it is just an empty array. v2 is going to address that.

    Allan

  • aklietzaklietz Posts: 8Questions: 0Answers: 0

    I updated the test case to add data:[]. See http://live.datatables.net/muxavuxi/4/edit.

    The test case now shows an empty table with No matching records found. The error message is ignored and discarded.

    It does correctly dismiss the Processing... box.

    As a workaround what I plan to do is inspect the response in the ajax post-processing step using dataSrc and manually show the error as an alert box.

  • allanallan Posts: 63,572Questions: 1Answers: 10,482 Site admin
    edited June 2021

    You are absolutely right - DataTables isn't correctly handling the error parameter when ajax is being used as a function rather than a string or Ajax configuration object. I've committed the fix and it will be in the next release. The nightly will rebuild in the next 10 minutes and include the change if you want to try it sooner.

    Regards,
    Allan

  • aklietzaklietz Posts: 8Questions: 0Answers: 0

    Thank you!

    I really appreciate the fast response. You guys are the best.

Sign In or Register to comment.