PHP/JS/JQUERY: Smart method to Auto check/updating a points status

Posted by Azzyh on Stack Overflow See other posts from Stack Overflow or by Azzyh
Published on 2010-04-06T21:49:53Z Indexed on 2010/04/06 21:53 UTC
Read the original article Hit count: 218

Filed under:
|
|
|

Hello.

Hi everyone. 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.

© Stack Overflow or respective owner

Related posts about php

Related posts about js