Qasim Ali
2007-Apr-19 10:23 UTC
How to redirect to other action when it is called using ajax
Hi all, I am using javascript to call an action with some parameters. In that action i decide on the basis of parameters either to render some text on that page or to re direct to some other page. But its seems that my redirect_to method is not working from that action. Can anybody tell me some way of redirecting to some other action when that action is called as a remote_function from javascript. Thanks -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Jeff Pritchard
2007-Apr-19 15:19 UTC
Re: How to redirect to other action when it is called using
Qasim Ali wrote:> Hi all, > > I am using javascript to call an action with some parameters. In that > action i decide on the basis of parameters either to render some text on > that page or to re direct to some other page. But its seems that my > redirect_to method is not working from that action. Can anybody tell me > some way of redirecting to some other action when that action is > called as a remote_function from javascript. > > ThanksIt is unclear whether you are wanting to "leave ajax" at that point and render a new rhtml page, or if you are wanting to "stay in ajax", and do some sort of a "render :update" in that second action. The answer depends on which way you are wanting to go here. In general, the "render :update redirect_to" will boot you out of the ajax sequence back into a normal full page rendering. To just re-route your logic to another action, you can just call that action as a method from the first action. You have to take care to only do one rendering regardless of which path your logic takes. jp -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Apparently Analagous Threads
- Execute controller function from RJS
- Can only render or redirect once per action - why?
- Ajax.Request w/standard redirect doesn''t render
- request.xhr? is false after redirecting an AJAX request?
- Dynamic drop-downs in a form_for using AJAX remote_function - Help