Forum: Ruby on Rails How to marshal Javascript data?

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.
Bradley M. (Guest)
on 2006-05-24 18:26
(Received via mailing list)
I'm trying to marshal some information I have in Javascript, and send
it over an AJAX request to the server, specifically to be stored in a
model on the server side.

I have some Javascript routines I wrote that gather information about
the user selection.  I see that the link_to_remote has a :before
option in which I can write Javascript to collect what I need, but
right now I'm at a bit of a loss as to how to do it.

What I would like to do is present the user with a link.  On
invocation of the link, my Javascript function is invoked, returning
an object with all the relevent data I need (mostly just numeric
data).  Now I want to send the data to the server.

How do I marshall that data up and send it to the server?  Do I have
to somehow wrap all this in some sort of form containing only hidden
fields?  Am I coming at this from the right direction?  What's the
right way to do it?

Thanks,
  Brad
Roberto S. (Guest)
on 2006-05-24 21:19
(Received via mailing list)
just use javascirpt and the prototype.js lib directly and not just the
rails
helper and you get all you need.  if you send the data as
JSON-serialized,
than it is easy to handle it at rails serverside, but I do not know
whether
prototype.js has specific JSON support.
This topic is locked and can not be replied to.