Add params to link :method=>POST

Hi Guys,

I hava a link that send via ajax some data. In this link I want to insert some params… How can I do this?


Bruno Meira

I’m using link_to helper

unless u add a params you can use an untrobusive javasscript.. something
like this:

link_to "something", :onclick => "someFunc("

function someFunc(email){
    url: '/my_url',
    type: 'POST',
    data: {email: email}, // parameter
    success: function(data, textStatus, xhr) {
     // success callback
    error: function (data, textStatus, xhr) {
      // error callback

Rifki, just a little fix:
link_to "something", :onclick => "someFunc(<= %>)"

And again.. damn.. i need to get some sleep =)

link_to "something", :onclick => "someFunc(<%=

I found the answer…

I fixed this problem using:

$("#addContactsToUser").bind(“ajax:before”, function()


$(this).data('params', { test: 'bar' });


As you can notice I insert post params before send my request.
This solution works ok ;D