[jQuery] bind a callback to ajax failures
Hi all,
Here's what I would like to do :
For all ajax request made in the current running page, whatever event
or dom node the ajax request is bound to, I would like be able to bind
a function in case of a failure of this request.
The function triggered would $.post() something to a page, but of
course, if this $.post() fails itself, I don't want the function to be
recalled again and again infinitely.
I saw in the doc there was ajaxError( callback ) but I don't know if
it is usable in my case
In the example stated here http://docs.jquery.com/Ajax/ajaxError#callback
$("#msg").ajaxError(function(event, request, settings){
$(this).append("<li>Error requesting page " + settings.url + "</li>");
});
I don't understand why it is attached to the dom node #msg ? What does
means $("#msg").ajaxError() ? Does it means all ajax request made with
$("#msg").load() ?
--
Fabien Meghazi
Website: http://www.amigrave.com
Email: agr@amigrave.com
IM: amigrave@gmail.com