AJAX redirect, with absolute URL, corrupts the URL


#1

I’m trying to redirect the browser to a URL outside of my domain on
some AJAX calls.
I do:

page.redirect_to(some_url)

It works fine with internal URLs, when I supply the :action
and :controller, but absolute URLs fail. Rails insists on applying
HTML encoding to the URL, thus replacing the & signs between arguments
to &

  • Same thing happens if I do the redirect from the .rjs template or
    from the controller.

Do I need to do something else to get this working?

Thanks,
Amir


#2

Thanks Phlip,

That works great.

Amir


#3

helzer wrote:

page.redirect_to(some_url)

It works fine with internal URLs, when I supply the :action
and :controller, but absolute URLs fail. Rails insists on applying
HTML encoding to the URL, thus replacing the & signs between arguments
to &

That might be an insect. Try more raw JavaScript:

page << “window.location.href = ‘#{my_uri}’;”


Phlip
http://www.oreilly.com/catalog/9780596510657/
“Test Driven Ajax (on Rails)”
assert_xpath, assert_javascript, & assert_ajax