Specifically:

927       dispatchException: function(exception) {
928         (this.options.onException || Prototype.emptyFunction)(this, 
exception);
929         Ajax.Responders.dispatch('onException', this, exception);
930       }

That block of code is excecuted if there is a code exception with any
part of the Ajax request. This method is called throughout the Ajax
object and is called at the first sign of trouble in any of the
blocks.

A simple usage example is as follows:

new Ajax.Request('index.html',{
   method: 'get',
   onComplete: function(request,json) {
      alert('request successful: ' + request.responseText);
      alert("I will cause a failure and onException should be
called..." + some_var);
   },
   onException: function(e) {
      alert("There was an error! Oh noes!\n" + e);
   }
});

Enjoy.

-E

On 12/15/06, Eric Harrison <[EMAIL PROTECTED]> wrote:
> You can try the predefined events:
>
> onError, onException, onFailure
>
> -E
>
> On 12/14/06, JRigby <[EMAIL PROTECTED]> wrote:
> >
> > How do you guys/girls trap Javascript errors in oncomplete and
> > afterfinish? The browser nor FireBug reports JS errors that occur in
> > this block. It just stops processing with no indication of where the
> > error occurred.
> >
> > Currently I use a try/catch statement and print the error in the catch.
> > Something like this:
> >
> > new Ajax.Updater('div', 'page.html', {
> >     onComplete: function(t) {
> >         try {
> >            //some code
> >         }
> >         catch(err) {
> >            alert("There was an Error:\n" + err);
> >         }
> > });
> >
> >
> > Are there better methods?
> >
> > Thanks
> >
> >
> > > >
> >
>
>
> --
> Eric Ryan Harrison
>


-- 
Eric Ryan Harrison

--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups 
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to