Reputation: 7585
I am trying to add a like button to a post in my RoR application. The two models I have are Post
and Like
.
On my webpage I am going to put the like button right next to the post button, but when users click the like button, I would like to have th request run in the background and not have to refresh the page.
Does anyone know of a simple way I could do this or where I can learn more about how to do it?
I am using the jQuery JavaScript library in my Rails application.
Upvotes: 0
Views: 139
Reputation: 15835
You can use jquery's ajax
api here
http://api.jquery.com/jQuery.ajax/
or even this one
http://jqapi.com/#p=jQuery.ajax
Upvotes: 1
Reputation: 1423
If you're using jQuery, you should use the jQuery.ajax() method, or one of it's deriviatives depending on your purposes. It runs in the background, and is very easy to use.
Upvotes: 2