How to redirect to other action when it is called using ajax


#1

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


#2

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.

Thanks

It 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