# Authenticity problem with jrails ajax

**URL:** <https://www.ruby-forum.com/t/authenticity-problem-with-jrails-ajax/165086>\
**Category:** Rails\
**Created:** [April 8, 2009, 11:52pm UTC](https://www.ruby-forum.com/t/authenticity-problem-with-jrails-ajax/165086 "2009-04-08T23:52:49Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [April 8, 2009, 11:52pm UTC](https://www.ruby-forum.com/t/authenticity-problem-with-jrails-ajax/165086/1 "2009-04-08T23:52:49Z")

</div>

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’})
