Metoda jQuery ajaxError().

❮ Metody jQuery AJAX

Příklad

Spustit výstražné okno, když selže požadavek AJAX:

$(document).ajaxError(function(){
  alert("An error occurred!");
});

Definice a použití

Metoda ajaxError() určuje funkci, která se má spustit, když selže požadavek AJAX.

Poznámka: Od verze jQuery 1.8 by tato metoda měla být připojena pouze k dokumentu.


Syntax

$(document).ajaxError(function(event,xhr,options,exc))

Parameter Description
function(event,xhr,options,exc) Required. Specifies the function to run if the request fails
Additional parameters:
  • event - contains the event object
  • xhr - contains the XMLHttpRequest object
  • options - contains the options used in the AJAX request
  • exc - contains the JavaScript exception, if one occurred

Zkuste si to sami - příklady


Jak používat parametr options k získání užitečnější chybové zprávy.


❮ Metody jQuery AJAX