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?
thx
Bruno M.
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?
thx
Bruno M.
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(current_user.email)”
function someFunc(email){
$.ajax({
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(<= current_user.email %>)”
And again… damn… i need to get some sleep =)
link_to “something”, :onclick => “someFunc(<%= current_user.email
%>)”
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
Thx
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs