Custom error not showing since 1.10.9

Custom error not showing since 1.10.9

yayaiyayai Posts: 2Questions: 1Answers: 0
edited November 2020 in Free community support

I created a simple fiddle to demonstrate the issue https://jsfiddle.net/320t98L6/1

Basically the 'on error' event does not seem to trigger in the latest version 1.10.22 (jquery 3.4.1)

If you use version 1.10.9 or lower, it works as intended. Any help is greatly appreciated

Sample code below:

$.fn.dataTable.ext.errMode = 'none';
$('#example').on('error.dt', function(e, settings, techNote, message) {
   alert( 'An error has been reported by DataTables: ', message );
})
$("#example").DataTable();

Edited by Colin - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

Answers

  • colincolin Posts: 15,144Questions: 1Answers: 2,586

    I tried it here with 1.10.8, and it does the same as yours, so I'm not seeing a behavioural change. We'll take a look and report back,

    Colin

  • allanallan Posts: 61,726Questions: 1Answers: 10,110 Site admin

    https://jsfiddle.net/CloudTables/Lae9gv02/1/

    error is still triggering, but it only triggers for errors that DataTables "knows" about - i.e. the Ajax response being invalid JSON. We specifically trigger error messages for some error states.

    The case where the columns in the header and the body don't match in length, appears to be an error that DataTables is no longer throwing its own message about. Rather there is a generic JS error being thrown.

    I'll have a look and see how we can improve our error messages for this state.

    Allan

  • yayaiyayai Posts: 2Questions: 1Answers: 0

    Thanks for the reply but actually on my case, I just needed it to alert some message returned from the server side, something like below:

    {"error":"Some error here","data":""}
    

    This use to work before, but it stopped, somewhere along the way when I upgraded to 1.10.16 or jquery 3.4.1

    My code is a bit of a mess now, in the middle of upgrading, so cant really pin point yet where the actual issue is, but I'll keep both of you posted if I found anything.

This discussion has been closed.