heispsychotic-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2006-Oct-16 16:11 UTC
Ajax.Request How To Return Error?
I noticed that Ajax.Request has a few responces onSuccess, on404 and onError. The first two are fairly self explanitory however i have some questions about onError. Is it possilbe for my php script that processes the Ajax request to some how trigger the onError responce? Thanks in advance. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
You could use your php script to send some http response code (hypothetical value like 101) and then use on101 to process it. The on<> handlers are not just limited to what you see, you can use any of them as long as you follow the convention. Please do wait to see what others have to say. Thanks, Mandy. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Hey there, heispsychotic-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org a écrit :> I noticed that Ajax.Request has a few responces onSuccess, on404 and > onError. The first two are fairly self explanitory however i have some > questions about onError. Is it possilbe for my php script that > processes the Ajax request to some how trigger the onError responce?There''s no such thing as onError. The events handled by A.R are, in chronological order for a given request/response sequence : - onLoading (internal) - onLoaded: triggered when the XHR object has been readied - onInteractive (mostly internal): triggered during response fetching - onXYZ/onSuccess/onFailure: triggered upon response fetching completion (see below for details) - onComplete: triggered *after* the selected callback above - onException: triggered if a JS exception occurs during the process When fetching the response has completed, A.R will first notify a callback based on the following algorithm: 1. If there''s a onXYZ where XYZ matches the response''s numeric code (HTTP status code, e.g. 404, 302, 500, whatever), it is used. 2. Failing that, if the response is deemed a success and there''s a onSuccess callback, it is used. If the response is deemed *not* a success (therefore, a failure), and there''s a onFailure callback, it is used. 3. onComplete, if defined, is called then. A response is deemed a success if any of those apply: a) it has no HTTP response status code b) it has a HTTP response status code of 0 (zero) c) it has a HTTP response status code in the 2yz range (200 to 299). ''HTH -- Christophe Porteneuve a.k.a. TDD "[They] did not know it was impossible, so they did it." --Mark Twain Email: tdd-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---