JQuery: Thumbs up and down rating system?

扶醉桌前 提交于 2019-12-21 02:59:26

问题


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


回答1:


jQuery

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:

PHP / MySQL

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);

?>



回答2:


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)




回答3:


Just Read the documentation of Jquery:

Rate me: Using Ajax

http://docs.jquery.com/Tutorials:Getting_Started_with_jQuery



来源:https://stackoverflow.com/questions/1049874/jquery-thumbs-up-and-down-rating-system

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!