JQuery:赞成或反对评级系统?

发布于 2024-07-25 17:56:53 字数 93 浏览 5 评论 0原文

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

谢谢

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

勿忘初心 2024-08-01 17:56:54

只需阅读 Jquery 的文档:

评价我:使用 Ajax

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

Just Read the documentation of Jquery:

Rate me: Using Ajax

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

北座城市 2024-08-01 17:56:53

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

?>

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

?>
眼趣 2024-08-01 17:56:53

这是一个使用 JQuery 并在 PHP/MySQL 中使用后端的样式。

代码链接(您可以在线尝试演示,所有源代码都在那里)

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)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文