Hi all, I have this code: new Ajax.Request(''non_existant.file'', { onSuccess:function(){alert("yay");}, onFailure:function(){alert("boo");} }); Why does the onFailure alert never get called? It works fine if I use a real file (onSuccess gets called). Thanks, Douglas
I believe onFailure is only a callback method for errors that happen on the server (you would have to have caught some kind of error condition in the server side code and explicitly initiated the onFailure method in your response), not on the client during the attempted transport/request to the server... I think what you want is: try { new Ajax.Request(''non_existant.file'', { onSuccess:function(){alert("yay");}, onFailure:function(){alert("boo");} }); } catch (e) { doSomething(); } -----Original Message----- From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Douglas Livingstone Sent: Tuesday, February 14, 2006 10:49 AM To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: [Rails-spinoffs] onFailure fails? Hi all, I have this code: new Ajax.Request(''non_existant.file'', { onSuccess:function(){alert("yay");}, onFailure:function(){alert("boo");} }); Why does the onFailure alert never get called? It works fine if I use a real file (onSuccess gets called). Thanks, Douglas _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs The information transmitted in this electronic mail is intended only for the person or entity to which it is addressed and may contain confidential, proprietary, and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from all computers.
2006/2/14, Ryan Gahl <Ryan.Gahl-nlycWCgr5/vuufBYgWm87A@public.gmane.org>:> I believe onFailure is only a callback method for errors that happen on > the server (you would have to have caught some kind of error condition > in the server side codeI''m looking to catch a 404 error here. Thanks, Douglas
Not sure then... I use my own AJAX classes. Hopefully someone else will chime in to help you. -----Original Message----- From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Douglas Livingstone Sent: Tuesday, February 14, 2006 10:59 AM To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: Re: [Rails-spinoffs] onFailure fails? 2006/2/14, Ryan Gahl <Ryan.Gahl-nlycWCgr5/vuufBYgWm87A@public.gmane.org>:> I believe onFailure is only a callback method for errors that happenon> the server (you would have to have caught some kind of error condition > in the server side codeI''m looking to catch a 404 error here. Thanks, Douglas _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs The information transmitted in this electronic mail is intended only for the person or entity to which it is addressed and may contain confidential, proprietary, and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from all computers.
There''s a on404 event you could catch: new Ajax.Request(''non_existant.file'', { onSuccess: function(){alert("yay");}, on404: function(){alert("404")} }) Ciao Martin www.pluxemburg.com On 14 feb 2006, at 17.58, Douglas Livingstone wrote:> 2006/2/14, Ryan Gahl <Ryan.Gahl-nlycWCgr5/vuufBYgWm87A@public.gmane.org>: >> I believe onFailure is only a callback method for errors that >> happen on >> the server (you would have to have caught some kind of error >> condition >> in the server side code > > I''m looking to catch a 404 error here. > > Thanks, > Douglas > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
2006/2/14, Martin Ström <mlists-99Sk8hLoGLv2eFz/2MeuCQ@public.gmane.org>:> There''s a on404 event you could catch: > > new Ajax.Request(''non_existant.file'', { > onSuccess: function(){alert("yay");}, > on404: function(){alert("404")} > }) > >Aah, thanks, that''s the trick. onFailure only gets called with a remote request. It means I can''t test this stuff locally without setting up a server... WebRICK here I come... Cheers, Douglas
Does anyone know what the serer should respond with to initiate onFailure? Douglas Livingstone wrote:> 2006/2/14, Martin Ström <mlists-99Sk8hLoGLv2eFz/2MeuCQ@public.gmane.org>: >> There''s a on404 event you could catch: >> >> new Ajax.Request(''non_existant.file'', { >> onSuccess: function(){alert("yay");}, >> on404: function(){alert("404")} >> }) >> >> > > Aah, thanks, that''s the trick. onFailure only gets called with a > remote request. It means I can''t test this stuff locally without > setting up a server... WebRICK here I come... > > Cheers, > Douglas > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
i think the function is triggered at a responsecode < 200 or > 300 eg. 404 brgds On 2/14/06, Robin Haswell <rob-gyMb1R/nBgNh8AIihN9Rc9BPR1lH4CV8@public.gmane.org> wrote:> > Does anyone know what the serer should respond with to initiate onFailure? > > Douglas Livingstone wrote: > > 2006/2/14, Martin Ström <mlists-99Sk8hLoGLv2eFz/2MeuCQ@public.gmane.org>: > >> There''s a on404 event you could catch: > >> > >> new Ajax.Request(''non_existant.file'', { > >> onSuccess: function(){alert("yay");}, > >> on404: function(){alert("404")} > >> }) > >> > >> > > > > Aah, thanks, that''s the trick. onFailure only gets called with a > > remote request. It means I can''t test this stuff locally without > > setting up a server... WebRICK here I come... > > > > Cheers, > > Douglas > > _______________________________________________ > > Rails-spinoffs mailing list > > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs >-- Mit freundlichen Grüßen Siegfried Puchbauer _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs