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 :D Bruno Meira -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
I''m using link_to helper -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
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
}
}
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
Rifki, just a little fix: link_to "something", :onclick => "someFunc(<= current_user.email %>)" On Dec 27, 10:36 am, Rifki Fauzi <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> 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 > } > > } > > -- > Posted viahttp://www.ruby-forum.com/.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
And again.. damn.. i need to get some sleep =) link_to "something", :onclick => "someFunc(<%= current_user.email %>)" On Dec 27, 1:30 pm, Alex Mercer <alexey.boby...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Rifki, just a little fix: > link_to "something", :onclick => "someFunc(<= current_user.email %>)" > > On Dec 27, 10:36 am, Rifki Fauzi <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: > > > > > > > > > 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 > > } > > > } > > > -- > > Posted viahttp://www.ruby-forum.com/.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
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
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.