An ajax call can error out if:
- it times out (per the timeout option)
- the server response status indicates an error (ie: 401, 404)
- an exception is thrown during the send operation
- an exception is thrown when processing the response
The last item above is especially interesting because it includes any
success handler you have defined (locally or globally).
If you define an "error" function, locally or via ajaxSettings, that
function is passed three args: the XHR, a status string (which will
always be "error") and an exception object if applicable. If you use
the ajaxError callback mechanism, via $().ajaxError(fn), there will be
four args passed to your fn: the event name (which will always be
"ajaxError"), the XHR, the ajax options used to submit the request,
and an exception object if applicable.
When in doubt, use firebug to put a breakpoint on your handler fn and
then "watch" the arguments variable.
Hope this helps.
Mike