[Rails] paramater passing with ajax in rails
view.html
<%= submit_tag "act",:id => params[:id], :class => "actcpn btn btn-success" %>
.js
$(".actcpn").click(function() {
$.ajax({
type: "PUT",
url: "http://localhost:3000/pgm/activate/",
success: function(){
$('.nplabel').fadeIn(300).show();
$('.nplabel').fadeOut(3000);
}
});
});
class PgmControlller
def activate
@coupon_id = params[:id]
end
Here the problem is i need to get the params[:id] in controller. so when the act button click in view, that will call the ajax through class .actcpn, where i give the url to the controller,How to pass that button id via that ajax url to controller?
Thanks
vishnu
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/2gzWsZv8J0UJ.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
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.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home