Responsive like button | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Responsive like button

How to make a responsive like button .when user hit the button it count the total number of like

8th May 2017, 3:44 PM
Hafiz Hamza
Hafiz Hamza - avatar
8 Answers
- 2
how about using ajax for instant refreshing of likes and saving too?
8th May 2017, 4:37 PM
Suhail Pappu
Suhail Pappu - avatar
+ 3
following
9th May 2017, 10:58 AM
Isomer
Isomer - avatar
+ 1
you have to save the counts in a file or a database. then when you refresh your page it should read the file or the database and display you.
8th May 2017, 4:16 PM
MR Programmer
MR Programmer - avatar
+ 1
JS: var x = 0; function addClick(){x++;} HTML: <button onclick="addClick()">Click Me!</button> Then if you want you could write X to the screen, or update the innerHTML of a string to show a counter.
8th May 2017, 4:25 PM
Raithen
Raithen - avatar
+ 1
@suhail facebook api usses an fb account to like any. post.
8th May 2017, 4:25 PM
MR Programmer
MR Programmer - avatar
+ 1
@Raithen the count will come back to zero when you refresh the page.
8th May 2017, 4:27 PM
MR Programmer
MR Programmer - avatar
0
@MR Programmer, correct although he did not specify saving it externally and loading it in later. For saving, read http://almostidle.com/tutorial/javascript-saving
8th May 2017, 4:35 PM
Raithen
Raithen - avatar
- 1
u can use facebook likes and comments API
8th May 2017, 4:15 PM
Suhail Pappu
Suhail Pappu - avatar