# Ajax.Request with page reload?

**URL:** <https://www.ruby-forum.com/t/ajax-request-with-page-reload/64279>\
**Category:** Rails\
**Created:** [June 23, 2006, 6:52pm UTC](https://www.ruby-forum.com/t/ajax-request-with-page-reload/64279 "2006-06-23T18:52:05Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![stickstone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/6f9a4e/32.png) [@stickstone](https://www.ruby-forum.com/u/stickstone)\
**Post date:** [June 23, 2006, 6:52pm UTC](https://www.ruby-forum.com/t/ajax-request-with-page-reload/64279/1 "2006-06-23T18:52:05Z")

</div>

I need to send a POST request via a link, along with paramater data for  
an action, and the page needs to reload. link\_to\_remote worked great  
when I was updating a DOM element but obviously won’t work when I need  
to reload a page. Is there an option

---

<div class="post-metadata">

**Author:** ![stickstone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/6f9a4e/32.png) [@stickstone](https://www.ruby-forum.com/u/stickstone)\
**Post date:** [June 23, 2006, 6:53pm UTC](https://www.ruby-forum.com/t/ajax-request-with-page-reload/64279/2 "2006-06-23T18:53:04Z")

</div>

hit return by mistake…

I need to send a POST request via a link, along with paramater data for  
an action, and the page needs to reload. link\_to\_remote worked great  
when I was updating a DOM element but obviously won’t work when I need  
to reload a page. Is there an option to force Ajax.request  
(link\_to\_remote) to reload the page?

---

<div class="post-metadata">

**Author:** ![stickstone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/6f9a4e/32.png) [@stickstone](https://www.ruby-forum.com/u/stickstone)\
**Post date:** [June 23, 2006, 7:23pm UTC](https://www.ruby-forum.com/t/ajax-request-with-page-reload/64279/3 "2006-06-23T19:23:14Z")

</div>

I thought that ajax is to send and receive data asynchronously from a  
server, without reloading the page, and optionally updating some parts  
of the current page by using DOM.

I wouldn’t use ajax to reload the page, instead I would use javascript,  
doing somethink like this:

var parameters = ‘var1=hello&var2=’ + $F(‘myTextField’);  
windows.location = ‘[http://mypage.com.ar/mycontroler](http://mypage.com.ar/mycontroler)’ + parameters;

Rodrigo D.

Iplan Networks Datos Personales  
removed\_email\_address@domain.invalid removed\_email\_address@domain.invalid  
www.iplan.com.ar www.rorra.com.ar  
5031-6303 15-5695-6027

-----Mensaje original-----  
De: removed\_email\_address@domain.invalid  
[[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)] En nombre de Brian  
Cardarella  
Enviado el: Viernes, 23 de Junio de 2006 01:53 p.m.  
Para: removed\_email\_address@domain.invalid  
Asunto: [Rails] Re: Ajax.Request with page reload?

hit return by mistake…

I need to send a POST request via a link, along with paramater data for  
an action, and the page needs to reload. link\_to\_remote worked great  
when I was updating a DOM element but obviously won’t work when I need  
to reload a page. Is there an option to force Ajax.request  
(link\_to\_remote) to reload the page?

–  
Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

* * *

Rails mailing list  
removed\_email\_address@domain.invalid  
[http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

---

<div class="post-metadata">

**Author:** ![stickstone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/6f9a4e/32.png) [@stickstone](https://www.ruby-forum.com/u/stickstone)\
**Post date:** [June 23, 2006, 7:28pm UTC](https://www.ruby-forum.com/t/ajax-request-with-page-reload/64279/4 "2006-06-23T19:28:26Z")

</div>

Brian C. wrote:

> hit return by mistake…
> 
> I need to send a POST request via a link, along with paramater data for  
> an action, and the page needs to reload. link\_to\_remote worked great  
> when I was updating a DOM element but obviously won’t work when I need  
> to reload a page. Is there an option to force Ajax.request  
> (link\_to\_remote) to reload the page?

Using RJS it’s easy:

page.redirect\_to(some\_url(:id =\> ‘foo’))

Or if you’re not using RJS templates, you can embed RJS in your link to  
remote tag:

link\_to\_remote(:url =\> (some\_url),  
:complete =\> render(:update) {|page| page.redirect\_to(some\_url)}  
)

Or if you’re don’t want to use RJS at all, I believe you can just use  
the javascript equivalent

window.location.href = ‘/some\_url/foo/1’;  
// Not completely sure of the above syntax but  
// its something like that

---

<div class="post-metadata">

**Author:** ![stickstone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/6f9a4e/32.png) [@stickstone](https://www.ruby-forum.com/u/stickstone)\
**Post date:** [June 24, 2006, 9:40am UTC](https://www.ruby-forum.com/t/ajax-request-with-page-reload/64279/5 "2006-06-24T09:40:36Z")

</div>

Hi Brian,

On Fri, 23 Jun 2006 18:53:04 +0200, Brian C. wrote:

> hit return by mistake…
> 
> I need to send a POST request via a link, along with paramater data for  
> an action, and the page needs to reload. link\_to\_remote worked great  
> when I was updating a DOM element but obviously won’t work when I need  
> to reload a page. Is there an option to force Ajax.request  
> (link\_to\_remote) to reload the page?

It sounds to me like you don’t want AJAX at all… just submit like a  
normal form which has a redirect\_to in the controller?

Trent
