Eric,
Thanks for taking the time to post your suggestions.
I like the onException bit, that helped this morning when I had a typo
in my javascript.
Yeah, those onException things are wonderful. I don't know what kind of
development environment you have, but I've found it most useful to
create a small development/debugging console for all of my pages that
those exceptions and warnings get dumped to. I can quickly rundown and
trace errors as they come up. Then for my userbase I merely use a
different function for their errors. Some errors I trap quietly and
other errors I display alerts to the user. It just depends on the
situation.
You may want to look into Ajax.Responders. I've not used it myself yet,
but if what I read is correct, you can configure all of your ajax
requests to function the same way by adding stuff to Ajax.Responders.
From what I've read, it seems like for something like onException,
you'd be able to put that into Ajax.Responders one time and then have
every one of your Ajax requests use that onException. Might save you
some time and might cut down on code doing the same thing appearing
everywhere you do a request.
The part that I'm still wrestling with is handling the 302 error. When
I manually kill my session (there's an eRights authentication plug-in
on our apache webserver), Firefox responds perfectly to "onFailure" and
even "on302" reporting a request.status of "302").
in IE6, on the other hand, nothing is getting triggered: onSuccess,
onComplete, onException, onFailure, on302.
This might be related the multiple redirects that happen when a user
session expires in our application and might be complicated by the
configuration of our development environment.
That may be entirely possible. To be completely honest with you, I've
never seen an ajax implementation responding to 302. Here at work where
we make heavy use of all kinds of insanely complicated ajax hackery, we
still try to completely avoid any and all server things like this if we
can.
We nicely handle 404's and 500's, but everything else we avoid like the
plague.
Given the information that Firefox runs the 302 stuff fine and IE is
the one that just dies, it would seem that this is another IE
shortcoming. I've not read anything about it yet anywhere on the
internet, so you may be the first person to discover this flaw. Might
be in everyones best interest to document the flaw and publish your
findings on a blog or something somewhere. Remember that strictly
speaking, IE 6 and below are using a retarded ActiveX object for it's
XHR stuff. If looking at their ActiveX implementation of standard HTML
select boxes is any indication, I wouldn't be surprised if it was
choking on the 302 and then not informing the js interpretter that an
error occurred.
For now, I think I'll look at setting a timeout on the request.
I'll let you know if I learn anything more,
Good luck. I appreciate it. This is an interesting problem and has a
lot of implications for future development ( for those of us who HAVE
to support IE ). I hope you can find a workaround without too much
hackery.
-E