PHP/JS/JQUERY:自动检查/更新积分状态的智能方法 [英] PHP/JS/JQUERY: Smart method to Auto check/updating a points status

查看:35
本文介绍了PHP/JS/JQUERY:自动检查/更新积分状态的智能方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以现在我正在使用这个:

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆