Hello together. I''ve tried to register an onFailure behavior for all my Ajax.Requests and .Updaters to handle a session-based timout system. On each server request via Ajax there is a check whether the user hasn''t made something for the last x minutes, and if he hasn''t, the php page throws an 403 forbidden header (via header("HTTP/1.1 403 Forbidden")). I am then trying to simply put an alert box and a redirect to the login page if that happens, but the onFailure code just won''t execute with the latest version 1.6 of prototype. I''m using this simple code: // Session Timeout Ajax.Responders.register({ onFailure: function() { alert(''Timeout!''); location.href=''/ login.php''; } }); The thing is, if I add this very function to the .Request or .Updater directly, it works just fine. Now I''ve found a patch for this problem, yet it is quite outdated and for an older version of Prototype: http://dev.rubyonrails.org/ticket/9643 Using the patch mentioned there, registering the onFailure works, but the alert box is thrown out *twice* before the redirect happens. Any suggestions on how to solve this (despite adding an onFailure behavior to every single Ajax call)? Any help appreciated, thank you. Robert --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
I have noticed another undesired behavior with the patch I added, which is that the onComplete script always fires, even if onFailure has triggered before. I was somewhat successful in working around this by using onSuccess instead of onComplete, yet this arises another problem, often occurring with Ajax.Updater calls. If the call hasn''t fully completed yet (but onSuccess already fired), onSuccess cannot access the content of the Updater response and therefore the script fails. Seeing the lack of answers to my posting, I wonder if this is really such an unusual functionality I am trying to accomplish? Does nobody know how to define a global onFailure procedure that will not interfere with onComplete (or rather, *does* interfere with it, by stopping it from firing)? Another way I could think of would be telling the onFailure call to stop any further script within an Ajax.Request or Ajax.Updater, especially any following onComplete, but I don''t know if that is possible, and therefore I''m hoping for your help on this. Regards, Robert --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---