JQuery: Thumbs up and down rating system?

前端 未结 3 1481
忘掉有多难
忘掉有多难 2021-02-10 16:19

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

相关标签:
3条回答
  • 2021-02-10 16:32

    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);
    
    ?>
    
    0 讨论(0)
  • 2021-02-10 16:33

    Just Read the documentation of Jquery:

    Rate me: Using Ajax

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

    0 讨论(0)
  • 2021-02-10 16:45

    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)

    0 讨论(0)
提交回复
热议问题