Forum: Ruby on Rails authenticity problem with jrails ajax

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.
71477e5162d702dae2a072d66a855fec?d=identicon&s=25 wbsurfver@yahoo.com (Guest)
on 2009-04-08 23:52
(Received via mailing list)
I'm using jrails and I found when I use the authenticity_token in
certain javascript calls, that the
url works differently in that the paramters in the :with clause get
dropped if they are in a json type syntax.
Below is an example of a remote_function() call from JS that used to
work fine without authenticity.
When I enabled authenticity it adds the authenticity token
automatically, but drops sending the
data in the :with part. I commented out this code as shown and
inserted an actual ajax call that does work fine, with authenticity,
but seems like not as much of the prefered approach. I've had similar
problems with field_observer() calls in some cases. I think if the
json syntax is not used when there is just one parameter, it does
work.

function update_server(info)
{

<%#= remote_function(:url => {:action => 'resize_field'},
                              :with =>
'{col:info.col,width:info.width}') # auth-OK
                               %>
$.ajax({data:
{col:info.col,width:info.width,authenticity_token:FORM_AUTH_TOKEN},
dataType:'script', type:'post', url:'/shgrid/resize_field'})
This topic is locked and can not be replied to.