Método jQuery ajaxError()

❮ Métodos jQuery AJAX

Ejemplo

Active un cuadro de alerta cuando falle una solicitud AJAX:

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

Definición y uso

El método ajaxError() especifica una función que se ejecutará cuando falle una solicitud AJAX.

Nota: a partir de la versión 1.8 de jQuery, este método solo debe adjuntarse al documento.


Sintaxis

$(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

Pruébelo usted mismo - Ejemplos


Cómo usar el parámetro de opciones para obtener un mensaje de error más útil.


❮ Métodos jQuery AJAX