PHP/JS/JQUERY:自动检查/更新积分状态的智能方法 [英] PHP/JS/JQUERY: Smart method to Auto check/updating a points status
问题描述
所以现在我正在使用这个:
function checkpoints() {
var postThis = 'checker.php?userid='+ $('#user_id_points').val();
$.post(postThis, function(data){
$(".vispoints").html(data).find(".vispoints1").fadeIn("slow")
});
setTimeout(checkpoints, 5000);
}
此功能每5秒钟重复一次(每5秒钟发送一次请求),并每5秒钟运行一次checker.php,以显示您获得了多少分. (checker.php回显您在span类vispoints1中获得了多少分).
现在没有一种更聪明的方法来执行此操作,而不是一直发送这样的请求..我的意思是像Facebook这样的网站,他们不喜欢这样检查您是否收到了新的朋友请求?
希望您能帮助我找到更好的方法示例,这也很好.
您可以通过搜索诸如
之类的关键字来寻找想法彗星,Ajax推送,反向Ajax等. >
So right now I am using me of this:
function checkpoints() {
var postThis = 'checker.php?userid='+ $('#user_id_points').val();
$.post(postThis, function(data){
$(".vispoints").html(data).find(".vispoints1").fadeIn("slow")
});
setTimeout(checkpoints, 5000);
}
This function repeats each 5 seconds (sending request each 5 seconds) and running the checker.php each 5 seconds, to show how many points you got. (checker.php echo out how many points you've got in a span class vispoints1).
Now isnt there a smarter method doing this, instead of sending requests like this all the time.. I mean sites like facebook and that, they dont do like this to check if you e.g got a new friend request?
Hope you can help me find a better method examples would be good too.
You can look into the ideas which can be found by searching for keywords like
Comet, Ajax Push, Reverse Ajax, ....
这篇关于PHP/JS/JQUERY:自动检查/更新积分状态的智能方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!