javascript - JQuery:竖起大拇指和不竖起大拇指的评级系统?

标签 javascript jquery ajax rating

我想在我的 web 应用程序中使用 jquery 实现点赞和点赞评分系统。请告诉我一些插件或代码如何在我的网站上实现点赞和点赞评分系统,请分享链接或资源。

谢谢

最佳答案

jQuery

这无非是一个翻车效果,一个等待更新数据库条目的地址。这不是真正的 jQuery。这其中的“核心”是您的数据库和服务器端脚本。

$("a.voteup").click(function(){
  $.get("updatescore.php", {"id":"112","score":"1"}, function(response){
    /* Do something with the response */
  });
});

该代码可能有点偏离,但它足以表达要点。从那里,您将有一个服务器端脚本等待接收这个:

PHP/MySQL

重要提示:不要按原样使用。仅供演示。
ASP.NET:我从您过去的问题中注意到您可能正在使用 .NET 技术。此处完成的过程仍然会失败。您将处理传入的请求,要求用户登录,他们的分数为 1 或 -1,以及您希望的任何其他内容。

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

?>

关于javascript - JQuery:竖起大拇指和不竖起大拇指的评级系统?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1049874/

相关文章:

javascript - 在更改图像 src 时提供 fadeIn fadeOut 效果

php - 使用 ajax 向数据库添加恰好 100 个值

c# - Ajax 请求在 HandleUnauthorizedRequest 之前命中错误函数

ajax - 使用 MooTools 在任何 ajax 请求上自定义 header

javascript - 页面上有多个视频需要自动播放单击的按钮之一

javascript - css div 破坏容器并掉落到下面的另一个

javascript - 输入日期字段应仅显示月份和年份

jquery - 如何在删除 sortable 时删除样式属性?

jQuery float 标题很滞后

javascript - 无法使用 CSS 在另一个图像上添加一个图像