Hello All, I''m trying to capture the exception message that my server application is providing in response to my Ajax.Request. However, I''m confused as to when onFailure is fired vs. onException. The onException handler has access to the javascript exception object and I''d understood that it was only called when the dispatch fails. Not sure what exactly that means and why an exception on the server-side sometimes triggers onFailure and sometimes onException. Can anyone clarify for me? Thanks! -- john --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
On 04/01/2008, John Cartwright <john.c.cartwright-Wuw85uim5zDR7s880joybQ@public.gmane.org> wrote:> > Hello All, > > I''m trying to capture the exception message that my server application > is providing in response to my Ajax.Request. However, I''m confused as > to when onFailure is fired vs. onException. The onException handler has > access to the javascript exception object and I''d understood that it was > only called when the dispatch fails. Not sure what exactly that means > and why an exception on the server-side sometimes triggers onFailure and > sometimes onException. > > Can anyone clarify for me? > > Thanks! > > -- johnAs I understand it ... onSuccess is called if the AJAX request completes and returns something. If the server produces an error, but outputs it as a normal page, then this is a success from the Ajax perspective. onFailure is called when the AJAX request fails. Say the request cannot be completed due to a bad URL or the server scripting sets a header which is an error, then this is how onFailure is called. onException is called when the JS code in the AJAX class fails. Say you try to access a property of a JSON object when the object doesn''t exist. -- ----- Richard Quadling Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731 "Standing on the shoulders of some very clever giants!" --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Hi, To clarify: onSuccess: status code >= 200 && =< 300 onFailure: every other status code onException: when an error is thrown (this can include dropped connection in certain browser-dependant cases). Best, Tobie On Jan 4, 11:21 am, "Richard Quadling" <rquadl...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> On 04/01/2008, John Cartwright <john.c.cartwri...-Wuw85uim5zDR7s880joybQ@public.gmane.org> wrote: > > > > > Hello All, > > > I''m trying to capture the exception message that my server application > > is providing in response to my Ajax.Request. However, I''m confused as > > to when onFailure is fired vs. onException. The onException handler has > > access to the javascript exception object and I''d understood that it was > > only called when the dispatch fails. Not sure what exactly that means > > and why an exception on the server-side sometimes triggers onFailure and > > sometimes onException. > > > Can anyone clarify for me? > > > Thanks! > > > -- john > > As I understand it ... > > onSuccess is called if the AJAX request completes and returns > something. If the server produces an error, but outputs it as a normal > page, then this is a success from the Ajax perspective. > > onFailure is called when the AJAX request fails. Say the request > cannot be completed due to a bad URL or the server scripting sets a > header which is an error, then this is how onFailure is called. > > onException is called when the JS code in the AJAX class fails. Say > you try to access a property of a JSON object when the object doesn''t > exist. > > -- > ----- > Richard Quadling > Zend Certified Engineer :http://zend.com/zce.php?c=ZEND002498&r=213474731 > "Standing on the shoulders of some very clever giants!"--~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Hi Tobie, Thanks for your prompt reply and for the clarification. The onException then will never get called if the server has an exception and returns HTTP status 500 - is that correct? Can you give me an example of how a server-side error might trigger the onException? Thanks again for your help! -- john Tobie Langel wrote:> Hi, > > To clarify: > > onSuccess: status code >= 200 && =< 300 > onFailure: every other status code > onException: when an error is thrown (this can include dropped > connection in certain browser-dependant cases). > > Best, > > Tobie > > On Jan 4, 11:21 am, "Richard Quadling" <rquadl...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> > wrote: > >> On 04/01/2008, John Cartwright <john.c.cartwri...-Wuw85uim5zDR7s880joybQ@public.gmane.org> wrote: >> >> >> >> >>> Hello All, >>> >>> I''m trying to capture the exception message that my server application >>> is providing in response to my Ajax.Request. However, I''m confused as >>> to when onFailure is fired vs. onException. The onException handler has >>> access to the javascript exception object and I''d understood that it was >>> only called when the dispatch fails. Not sure what exactly that means >>> and why an exception on the server-side sometimes triggers onFailure and >>> sometimes onException. >>> >>> Can anyone clarify for me? >>> >>> Thanks! >>> >>> -- john >>> >> As I understand it ... >> >> onSuccess is called if the AJAX request completes and returns >> something. If the server produces an error, but outputs it as a normal >> page, then this is a success from the Ajax perspective. >> >> onFailure is called when the AJAX request fails. Say the request >> cannot be completed due to a bad URL or the server scripting sets a >> header which is an error, then this is how onFailure is called. >> >> onException is called when the JS code in the AJAX class fails. Say >> you try to access a property of a JSON object when the object doesn''t >> exist. >> >> -- >> ----- >> Richard Quadling >> Zend Certified Engineer :http://zend.com/zce.php?c=ZEND002498&r=213474731 >> "Standing on the shoulders of some very clever giants!" >> > > > >--~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
> The onException then will never get called if the server has an > exception and returns HTTP status 500 - is that correct?Afaik yes. Though you could get an exception thrown for that if Ajax.Request tried to evaluate the response (if your mime-type is incorrectly set to text/javascript, for example).> Can you give me an example of how a server-side error might trigger the > onException?A dropped connection triggers an error in FF afaik. --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Thanks Richard, that''s very helpful. One last clarification: When you say that onFailure will be triggered when "server scripting sets a header which is an error" do you mean an HTTP status code in the 500 range or is there a particular header that is looked for? -- john Richard Quadling wrote:> On 04/01/2008, John Cartwright <john.c.cartwright-Wuw85uim5zDR7s880joybQ@public.gmane.org> wrote: > >> Hello All, >> >> I''m trying to capture the exception message that my server application >> is providing in response to my Ajax.Request. However, I''m confused as >> to when onFailure is fired vs. onException. The onException handler has >> access to the javascript exception object and I''d understood that it was >> only called when the dispatch fails. Not sure what exactly that means >> and why an exception on the server-side sometimes triggers onFailure and >> sometimes onException. >> >> Can anyone clarify for me? >> >> Thanks! >> >> -- john >> > > As I understand it ... > > onSuccess is called if the AJAX request completes and returns > something. If the server produces an error, but outputs it as a normal > page, then this is a success from the Ajax perspective. > > onFailure is called when the AJAX request fails. Say the request > cannot be completed due to a bad URL or the server scripting sets a > header which is an error, then this is how onFailure is called. > > onException is called when the JS code in the AJAX class fails. Say > you try to access a property of a JSON object when the object doesn''t > exist. > > > >--~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
On 04/01/2008, John Cartwright <john.c.cartwright-Wuw85uim5zDR7s880joybQ@public.gmane.org> wrote:> > Thanks Richard, that''s very helpful. One last clarification: When you > say that onFailure will be triggered when "server scripting sets a > header which is an error" do you mean an HTTP status code in the 500 > range or is there a particular header that is looked for? > > -- johnI mean setting a return HTTP status code outside of the "Success" range. I do not look for a particular header. Sorry for the confusion.> > > Richard Quadling wrote: > > On 04/01/2008, John Cartwright <john.c.cartwright-Wuw85uim5zDR7s880joybQ@public.gmane.org> wrote: > > > >> Hello All, > >> > >> I''m trying to capture the exception message that my server application > >> is providing in response to my Ajax.Request. However, I''m confused as > >> to when onFailure is fired vs. onException. The onException handler has > >> access to the javascript exception object and I''d understood that it was > >> only called when the dispatch fails. Not sure what exactly that means > >> and why an exception on the server-side sometimes triggers onFailure and > >> sometimes onException. > >> > >> Can anyone clarify for me? > >> > >> Thanks! > >> > >> -- john > >> > > > > As I understand it ... > > > > onSuccess is called if the AJAX request completes and returns > > something. If the server produces an error, but outputs it as a normal > > page, then this is a success from the Ajax perspective. > > > > onFailure is called when the AJAX request fails. Say the request > > cannot be completed due to a bad URL or the server scripting sets a > > header which is an error, then this is how onFailure is called. > > > > onException is called when the JS code in the AJAX class fails. Say > > you try to access a property of a JSON object when the object doesn''t > > exist. > > > > > > > > > > > > >-- ----- Richard Quadling Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731 "Standing on the shoulders of some very clever giants!" --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---