Pra*_*ant 4 javascript ajax jquery rating
我想使用jquery在我的网络应用程序中实现拇指向上和向下评级系统.请告诉我一些插件或代码如何在我的网站上实现拇指向上和向下评级系统,请分享链接或资源.
谢谢
Sam*_*son 13
这只是一个翻转效果,以及等待更新数据库条目的地址.这不是真正的jQuery.这种"肉"将是您的数据库和服务器端脚本.
$("a.voteup").click(function(){
$.get("updatescore.php", {"id":"112","score":"1"}, function(response){
/* Do something with the response */
});
});
Run Code Online (Sandbox Code Playgroud)
该代码可能有点偏,但它足够接近传达这一点.从那里,您将有一个服务器端脚本等待接收:
重要提示:请勿使用原样.仅用于演示.
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);
?>
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
12715 次 |
最近记录: |