DataTables Ajax Error, can I catch this and redirect?

DataTables Ajax Error, can I catch this and redirect?

morrtymorrty Posts: 29Questions: 6Answers: 0

I have an application that users have to sign into with authentication to use and it uses DataTables on one of the pages. I use an ajax source and ever 5 minutes I'm triggering a

datatable.ajax.reload(null, false);

The problem I'm having is that if a user signs out (maybe they had multiple tabs open?) then when the above command is triggered, I get a pop up saying ajax error with datatables (because they're signed out and I'm providing a 401/403 response instead of JSON).

How can I instead of having an ajax error pop up show, redirect the user to the sign in page when a 401/403 response is returned?

This question has an accepted answers - jump to answer

Answers

  • morrtymorrty Posts: 29Questions: 6Answers: 0

    I see there is an xhr and prexhr event. Can I do something with these?

  • allanallan Posts: 63,678Questions: 1Answers: 10,498 Site admin
    Answer ✓

    The $.fn.dataTable.ext.errMode option can be used for this. See the documentation in the error event.

    Allan

This discussion has been closed.