jquery and server issue

Discussion in 'jQuery' started by commandos, Dec 30, 2008.

  1. #1
    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>
    Code (markup):

    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)
     
    commandos, Dec 30, 2008 IP
  2. zerxer

    zerxer Peon

    Messages:
    368
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    0
    #2
    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.
     
    zerxer, Jan 1, 2009 IP