hwrdprkns
hwrdprkns

Reputation: 7585

Adding a like button to a post that doesn't refresh the page

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

Answers (2)

kobe
kobe

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

esteuart
esteuart

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

Related Questions