Ajax Call redirect to a full page refresh

Hi,

Let s assume my controller gets a ajax call… I will start the
process to to the appropriate actions…
During the process I discover that the changes are too complex and I
cannot provide the user the response with just an ajax response…
instead I would need a full page fresh…

Unfortunelty, I ve got no idea how to solve this… :frowning:

Thanks a lot in advance…

Volker

On Mar 6, 10:00 am, “[email protected]
[email protected] wrote:

Thanks a lot in advance…

Volker


def my_action
if changes_are_too_complex
redirect_to :action => ‘show’ …
else
# auto-render my_action.rjs template if its there
end
end

If you don’t do anything, you’ll get the template automatically. If
you do a redirect, the auto template will get skipped.

– Wes

Let s assume my controller gets a ajax call… During the process I discover that the changes are too complex and I
cannot provide the user the response with just an ajax response…instead I would need a full page fresh…

since you have in “page” the object representing your javascript
document, you could just send a client-side redirect to that object and
the browser would do the rest.

regards,

javier ramirez

Estamos de estreno… si necesitas llevar el control de tus gastos
visita http://www.gastosgem.com !!Es gratis!!

Unfortunately, I don’t believe that will work. From what I’ve seen,
what Wes’ solution will do is redraw the entire page inside of the
element specified in Ajax.Update, leading to a very odd looking
site-in-site effect. The best way I could think of doing it was to
send RJS back that does a simple “document.location = page_url”,
forcing the browser to reload the page from scratch.
if you are not using any “update” parameter when invoking ajax (and if
you use update you can change that easily), you can directly do
page.redirect_to whatever

you can do that in the rjs or directly on the controller by using render
:update. Behind the scenes it will do domething pretty similar to what
you propose, which is changing window.location.href. The advantage is
you can use the parameters of redirect_to and you don’t need to
implement anything at the server side

regards,

j


Estamos de estreno… si necesitas llevar el control de tus gastos
visita http://www.gastosgem.com !!Es gratis!!

Unfortunately, I don’t believe that will work. From what I’ve seen, what
Wes’ solution will do is redraw the entire page inside of the element
specified in Ajax.Update, leading to a very odd looking site-in-site
effect.

The best way I could think of doing it was to send RJS back that does a
simple “document.location = page_url”, forcing the browser to reload the
page from scratch.

Jason

On Mar 6, 10:50 am, “Jason R.” [email protected] wrote:

On 3/6/07, wesgarrison [email protected] wrote:

cannot provide the user the response with just an ajax response…
def my_action
– Wes
I could’a sworn that I’d used redirect_to instead of
page.redirect_to.
Anyway, you can do your processing to determine what “too complex”
means, then either render a redirect, render some js in the
controller, or pass it to a .rjs template.

– Wes

I would do something like

def my_action
if changes_are_too_complex
render :update do |page|
page.redirect_to :action => “show”
end
end
end

Also with the default my_action.rjs template (as indicated above).

-carl

On 3/6/07, wesgarrison [email protected] wrote:

redirect_to :action => 'show' ...


EPA Rating: 3000 Lines of Code / Gallon (of coffee)

My guess is that you just want cause the entire page to refresh… so
here is another option…

def my_action
#do stuff
if changes_are_too_complex
render :update do |page|
page.replace_html ‘message_to_user_div’, ‘Reloading
Page…

page.call ‘location.reload’
end
else
#do other stuff
end
end

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs