I'm want to implement thumbs up and down rating system in my web app using jquery. Please tell me some plug-in or code how to implement the thumbs up and down rating system in my website, please share links or resources.
Thanks
This is nothing more than a roll-over effect, and an address that waits to update a database entry. It's not really jQuery. The "meat" of this would be your database and server-side scripting.
$("a.voteup").click(function(){
$.get("updatescore.php", {"id":"112","score":"1"}, function(response){
/* Do something with the response */
});
});
That code may be a bit off, but it's close enough to convey the point. From there, you would have a server-side script waiting to receive this:
IMPORTANT: Do not use as-is. Only for demonstration.
ASP.NET: I noticed from your past questions you are likely working within the .NET technologies. The process done here will still be faily similar. You'll handle the incoming request, require the user to be logged in, their score to be 1 or -1, and whatever else you wish.
session_start();
$userid = $_SESSION["userid"];
$vote = $_GET["score"]; /* Limit to 1 or -1 */
$article = $_GET["id"];
/* Whatever is printed here will be the 'response' variable
over in our jQuery callback function. Ideally, this function
would only allow the vote if the following are true:
1. User has not yet voted on this article
2. Score is 1 or -1
3. Voting is enabled on this article
4. User is indeed logged in */
print castVote($article, $vote, $userid);
?>
here is a style with thumbs up and down using JQuery with a Backend in PHP/MySQL.
Link to code (You can try the demo online and all the source code is there)
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