Forum: Ruby on Rails Ajax.request -> Controller Variable?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
John M. (Guest)
on 2007-02-21 03:39
The amount of frustration that this has caused me has prompted me to
seek outside help. I know answer is right in front of me, but after
pouring over API documents and dozens of forum posts the answer still
eludes me:

I have a javascript func that detects the dimensions of the client
browser, I know I need to use an ajax.request to get the information
back to the controller - but for the life of me I cannot figure out how
to do that.

In my View:
new Ajax.Request('/main/gallery', {asynchronous:true, method:'get',

In my Controller:

@gallery_size = params[:size] unless params[:size].nil?

I would be eternally grateful for any response.
John M. (Guest)
on 2007-02-21 03:41
I forgot to mention that I have this encapsulated in a function that is
triggered by the page loading:

Event.observe(window, "load", start);
John M. (Guest)
on 2007-02-21 10:06
I finally solved the issue. Calling it in the body instead of on the
actual gallery page solved the problem, as well as just throwing it in a

Main Layout:
<body onload="new Ajax.Request('/main/set_width?client_screen_height=' +
clientScreenHeight(), {asynchronous:true, evalScripts:true}); return


def set_width
  session[:client_screen_height] = params[:client_screen_height]
This topic is locked and can not be replied to.