# Javascript/Prototype helper and redirect\_to

**URL:** <https://www.ruby-forum.com/t/javascript-prototype-helper-and-redirect-to/150079>\
**Category:** Rails\
**Created:** [October 3, 2008, 10:13am UTC](https://www.ruby-forum.com/t/javascript-prototype-helper-and-redirect-to/150079 "2008-10-03T10:13:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![david](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/aeb1de/32.png) [@david](https://www.ruby-forum.com/u/david)\
**Post date:** [October 3, 2008, 10:13am UTC](https://www.ruby-forum.com/t/javascript-prototype-helper-and-redirect-to/150079/1 "2008-10-03T10:13:37Z")

</div>

Is there a Javascript/Prototype helper with which you can use  
redirect\_to? Ive been searching all around and can’t seem to find any  
information about this. I need to use an ajax helper to send data  
from a javascript function. I have been using link\_to\_remote and  
passing the data like so: :with =\> “‘data=’+newFunction()”. But by  
using link\_to\_remote, I am unable to redirect to another action, which  
is somewhat limiting. Any input is appreciated. Thanks.

---

<div class="post-metadata">

**Author:** ![david](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/aeb1de/32.png) [@david](https://www.ruby-forum.com/u/david)\
**Post date:** [October 3, 2008, 10:27am UTC](https://www.ruby-forum.com/t/javascript-prototype-helper-and-redirect-to/150079/2 "2008-10-03T10:27:46Z")

</div>

David wrote:

> Is there a Javascript/Prototype helper with which you can use  
> redirect\_to? Ive been searching all around and can’t seem to find any  
> information about this. I need to use an ajax helper to send data  
> from a javascript function. I have been using link\_to\_remote and  
> passing the data like so: :with =\> “‘data=’+newFunction()”. But by  
> using link\_to\_remote, I am unable to redirect to another action, which  
> is somewhat limiting. Any input is appreciated. Thanks.

there is no redirect\_to helper for Ajax environment

you can use  
link\_to\_remote “Delete”, :update =\> “div\_id”,  
:url =\> {:controller=\>’’,:action=\>’’}, :method =\> :delete,  
:html =\> { :class =\> “divs” }  
or  
link\_to\_remote “Delete”, :update =\> “div\_id”, :url =\> { :action =\> “”,  
:id =\> @id }

---

<div class="post-metadata">

**Author:** ![david](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/aeb1de/32.png) [@david](https://www.ruby-forum.com/u/david)\
**Post date:** [October 3, 2008, 10:41am UTC](https://www.ruby-forum.com/t/javascript-prototype-helper-and-redirect-to/150079/3 "2008-10-03T10:41:43Z")

</div>

So is there any way to pass the result of a javascript function to an  
action in order to save information to the database and then use  
redirect\_to?

On Oct 3, 1:27 am, Pokkai D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![david](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/aeb1de/32.png) [@david](https://www.ruby-forum.com/u/david)\
**Post date:** [October 3, 2008, 10:47am UTC](https://www.ruby-forum.com/t/javascript-prototype-helper-and-redirect-to/150079/4 "2008-10-03T10:47:35Z")

</div>

On Oct 3, 9:40 am, David [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> So is there any way to pass the result of a javascript function to an  
> action in order to save information to the database and then use  
> redirect\_to?

The below information is wrong. When using rjs you can redirect (but  
you need to use page.redirect\_to, not redirect\_to)

Fred
