Hide "Loading..." message on AJAX error like 403, 404

Hide "Loading..." message on AJAX error like 403, 404

tstartstar Posts: 36Questions: 0Answers: 0
edited July 2012 in General
I'm use code like this:
[code]
$('#example').dataTable( {
"sAjaxSource": "xhr.php",
} );
[/code]
But when server return error like 403, 404, i can't found how i can handling this error and hide message "Loading..." or show message for user. May be i must use "fnServerData" property and handling AJAX error in $.ajax, but how when hide "Loading..." message?
Sorry for my English.
Thank you.

Replies

  • allanallan Posts: 63,542Questions: 1Answers: 10,476 Site admin
    I tend to leave it up because it indicates quite clearly that something has gone wrong and the developer should do something about it! However, if you want to hide it, you could use fnServerData to specify your own Ajax call with an 'error' handler that would call:

    [code]
    oSettings.oApi._fnProcessingDisplay( oSettings, false );
    [/code]

    There is an API method that uses this approach:
    http://datatables.net/plug-ins/api#fnProcessingIndicator

    Allan
  • tstartstar Posts: 36Questions: 0Answers: 0
    Thank you!
    I will definitely try it.
    As for me, the logical conclusion the message "Failed to load data" when not using fnServerData, because in IE6-7, some tables are creating very slow, and it is not clear what is actually happening. This would save a lot of time in my tests.
This discussion has been closed.