我想使用 jquery 在我的网络应用程序中实现竖起大拇指和向下评分系统。请告诉我一些插件或代码如何在我的网站上实现点赞和点赞系统,请分享链接或资源。
谢谢
我想使用 jquery 在我的网络应用程序中实现竖起大拇指和向下评分系统。请告诉我一些插件或代码如何在我的网站上实现点赞和点赞系统,请分享链接或资源。
谢谢
这只不过是一个翻转效果,一个等待更新数据库条目的地址。它不是真正的 jQuery。这其中的“肉”将是您的数据库和服务器端脚本。
$("a.voteup").click(function(){
$.get("updatescore.php", {"id":"112","score":"1"}, function(response){
/* Do something with the response */
});
});
该代码可能有点偏离,但足以传达这一点。从那里,您将有一个服务器端脚本等待接收:
重要提示:不要按原样使用。仅用于演示。
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);
?>
这是一种在 PHP/MySQL 中使用带有后端的 JQuery 竖起大拇指的风格。
代码链接(您可以在线尝试演示,所有源代码都在那里)