Debt Consolidation - Record Internet Radio with Tags - WoW Gold - Payday Loan - Christmas Ecards

PDA

View Full Version : jquery and server issue


commandos
Dec 30th 2008, 10:27 pm
i have a number let say ... number of visitors for a page (it's not that but similar in some way)

i'm using jquery to show how many visitors the site got , and i have a div that contain the number let say

<div id="counter"> </div>

and in the jquery i have the followings :

<script>

// the call for the update (it just change an entry in the db total = total + 1;
function autoupdate() {

$.post("count.php", {count:1},
function(data){
$("#counter").html(data);
});}

// the 1 sec interval
$(document).ready(function() {
setInterval("autoupdate()", 1000);
});
</script>


question : would that be too harsh on a server if it receive a lot of visitors ?

my aim is to show a live counter , with live update like gmail (like how many mb they are hosting .. i know their example is fake ...but wanted to do something similar)

zerxer
Jan 1st 2009, 10:42 pm
Maybe.. If you're loading it every second for every person that has the page open. It's not just that you're loading a page so much either, but you're connecting to a database each time and running an update query and I assume another query to get the new total. I'm really not sure what the best method would be.