Topic: Javascript + Rails. Get data into a controller without page reload?

Hey.
Ive seen this discussed in a few places online but havent seen anything quite like what im after.
I want to execute a Javascript function in the client browser Date.getTimezoneOffset() and then send that result back to the controller  to perform a special query based on the user's timezone.

How can i do this all on the one page view, without redirecting to a new URL?

Thanks!

Re: Javascript + Rails. Get data into a controller without page reload?

assuming you use query,  you could use the ajax function

http://api.jquery.com/category/ajax/

if you want to post,  you'll have to make sure you set the authenticity token

http://brandonaaron.net/blog/2009/02/24 … s-and-ajax

Joe got a job, on the day shift, at the Utility Muffin Research Kitchen, arrogantly twisting the sterile canvas snout of a fully charged icing anointment utensil.

Re: Javascript + Rails. Get data into a controller without page reload?

Thank you.
My javascript skills are non existant.

are you saying use the : jQuery.post() ?

thx

Re: Javascript + Rails. Get data into a controller without page reload?

No the ajax call of JQuery, using the POST HTTP verb.

The second link I posted shows how to set it up.  You have to send the Rails authenticity token in the header so that the rails system will accept the post request.  Normally it's handled by rails,  but you're building your own POST, and you have to put it in,  or Rails will reject the request.

Joe got a job, on the day shift, at the Utility Muffin Research Kitchen, arrogantly twisting the sterile canvas snout of a fully charged icing anointment utensil.

Re: Javascript + Rails. Get data into a controller without page reload?

Cool. thanks again