PHP/JS/JQUERY: Smart method to Auto check/updating a points status
- by Azzyh
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.