Using .ajaxError and passing error function in ajax calls
Hello,
I'm currently rewriting all my ajax calls to use the jquery method (much cleaner code!
) and have declared a default ajaxError function, shown below:
- $(document).ajaxError(function(event, request, settings){
alert("There was an error while communicating with the server. URL: " + settings.url);
});
However, now I have a few ajax calls where I want to declare an error function in the ajax call. I was hoping that by declaring an error function in the ajax call, it would replace the default error call I have defined. But that does not appear to be the case, as I continue to first get my ajax function error call, then I also see the above code execute.
I tried calling event.stopImmediatePropagation() from within my ajax error function hoping that it would stop further events firing (ie: the default error event) but that didn't do anything except tell me in firefox that "event" was undefined.
Any ideas? I was hoping I wouldn't have to go through and define an error function to EVERY ajax call. If it comes down to that, I will. Just figured I'd ask.
Thanks,
Matt