I setup the ajax error handler something like this:
$(document).ajaxError( ajaxErrorHandler );
function ajaxErrorHandler (e, jqXHR, settings, exception)
{
}
When I call $.ajax(options); I wish to pass a DOM element along w/ the ajax call so that I could read it in ajaxErrorHandler().
Is there a way to do this?
If you’re using $.ajax() itself to run your requests, then you can do this. Convenience methods like $.post won’t work.
Per the jQuery docs (and the signature in your example handler), the ajaxError handler receives the original settings object sent to $.ajax. You can add a reference to your DOM element in this settings object. The $.ajax method will ignore it, but it’ll pass it along with your other settings to the handlers!
Then, in the handler, you can retrieve the #puppies form with
settings.elm.