I have the following link_to method:
link_to "", votes_path(vote: { post_id: post.id, up: true}), method: :post, remote: true
and I'm trying to intercept the triggered AJAX call to manipulate the POST parameters. With a GET request this was quite easy because the parameters are stored under data:
$('#my_link').bind('ajax:before', function() {
$(this).data('params', { foo: 'bar' })
});
but that's not the case for POST request. Can someone tell me where the POST parameters are stored?
Nevermind I just found out myself.
What you have to do is just manipulate the href attribute from the first object in the link array:
$('#my_link').bind('ajax:before', function() {
$(this).first().attr('href', href + "&vote[custom_param]=customvalue");
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With