Forum: Ruby on Rails How do I get a javascript variable into rails

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Ce19ec02c50b0dd6a370ad4947f7a56d?d=identicon&s=25 Ali (Guest)
on 2008-12-11 10:50
(Received via mailing list)
Hi,

I'm new to ajax and I've a little problem to sending parameters in
order to be executed on the controller.

Suppose that "function updatextable(e)" which is javascript function
is called somewhere in the application (onDrop of draggable element).
How can I send "e.value" to the controller in order to do some active
record operations?

Many thanks
280b78a61a968391b7e07e912be102a8?d=identicon&s=25 Robert Walker (robert4723)
on 2008-12-12 19:01
> Suppose that "function updatextable(e)" which is javascript function
> is called somewhere in the application (onDrop of draggable element).
> How can I send "e.value" to the controller in order to do some active
> record operations?
I suppose the same way you send any data in a HTTP request, whether that
be by AJAX or not makes no difference.

GET: http://example.com/resource?e=value

POST: http://example.com/resource
-- Form data --
e=value
--

That is unless you want to take some more extreme measures like sending
data to the server using something other than HTTP (i.e. Adobe Flash, a
Java Applet, etc.).
8dad1ec4d769734583f45fbbee5cd009?d=identicon&s=25 Jeff Pritchard (jeffpritchard)
on 2008-12-13 07:33
Ali wrote:
> Hi,
>
> I'm new to ajax and I've a little problem to sending parameters in
> order to be executed on the controller.
>
> Suppose that "function updatextable(e)" which is javascript function
> is called somewhere in the application (onDrop of draggable element).
> How can I send "e.value" to the controller in order to do some active
> record operations?
>
> Many thanks

There is another topic right next to yours right now.  Have a look at:
http://www.ruby-forum.com/topic/172754#new

I think it will answer your question.

jp
This topic is locked and can not be replied to.