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

**URL:** <https://www.ruby-forum.com/t/how-to-redirect-to-other-action-when-it-is-called-using-ajax/92426>\
**Category:** Rails\
**Created:** [April 19, 2007, 12:23pm UTC](https://www.ruby-forum.com/t/how-to-redirect-to-other-action-when-it-is-called-using-ajax/92426 "2007-04-19T12:23:42Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![stanly](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/65b543/32.png) [@stanly](https://www.ruby-forum.com/u/stanly)\
**Post date:** [April 19, 2007, 12:23pm UTC](https://www.ruby-forum.com/t/how-to-redirect-to-other-action-when-it-is-called-using-ajax/92426/1 "2007-04-19T12:23:42Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![stanly](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/65b543/32.png) [@stanly](https://www.ruby-forum.com/u/stanly)\
**Post date:** [April 19, 2007, 5:19pm UTC](https://www.ruby-forum.com/t/how-to-redirect-to-other-action-when-it-is-called-using-ajax/92426/2 "2007-04-19T17:19:36Z")

</div>

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
