jQWidgets Forums

jQuery UI Widgets Forums Plugins Data Adapter Ajax Fail callback

This topic contains 1 reply, has 1 voice, and was last updated by  Pietervk 7 years, 11 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • Ajax Fail callback #94076

    Pietervk
    Participant

    Hi,
    I known there is a loadServerData property on the dataAdapter, that allows me to do the ajax call myself:

    loadServerData: function (serverdata, source, callback) {
    $.ajax({
    dataType: source.datatype,
    url: source.url,
    data: serverdata,
    success: function (data, status, xhr) {

    callback({ records: data.Tests, totalrecords: data.TotalRecords });
    }
    }).fail(function (jqXHr, textStatus, errorThrown) {

    });

    },

    Actually, I just need to catch the fail function, I don’t need to have the custom Ajax call. The grid is showing a status screen and is constantly being refreshed. At some point, the user is logged out. I would like to respond to this on the client side. Do you have any suggestions for this?

    Ajax Fail callback #94079

    Pietervk
    Participant

    Never mind, found it.

    $(document)
        .ajaxError(function (event, jqXHr, settings) {
               if (jqXHr.status == 401) {
               //fail gracefully
            }
        })

    This allows me to do away with the loadserverdata call alltogether

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.