I have an Ajax form with a data-remote=\"true\"
attribute which I\'m submitting to a controller in rails.
What I\'d like to do is to use the jquery-ujs even
I figured this one out myself in the end. It appears that despite what the docs say, the ajax:beforeSend
hook actually takes three arguments. According to this helpful blog post they are event
, xhr
and settings
in that order.
The form data I was looking for is in the in the data
attribute of the settings
argument.
So basically, I can now add data to the request with the function
$("#my_form").bind('ajax:beforeSend', function(event, xhr, settings){
settings.data += "&serialized=data";
});
And the extra paramaters will be available on the server.