Use Javscript to check user online

Discussion in 'JavaScript' started by imdavidlee, Apr 21, 2009.

  1. #1
    May i know how to write javascript to ping to server and show how many users online on browser? This concept same like facebook online friends. I heard my senior said that if using javascript, it will cause heavy load since it will take a lot of resources while using actionscript wont have such issue since the server can respond to the browser.

    I really dont have any idea how to write the javascript to check. Hopefully somebody here can give a helping hand. Thanks.

    <a href="http://codebasic.net">CodeBasic</a>
     
    imdavidlee, Apr 21, 2009 IP
  2. awatson

    awatson Active Member

    Messages:
    112
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    53
    #2
    You'd probably want to use ajax to grab a value off the server and show in on the page. jQuery makes this fairly easy. You'd need a php script or something running on the server. The ajax can call this script directly, which returns the number of users currently online. Or the script could run every 5 minutes (or whatever) and create a static file, which the ajax then grabs and uses. Depending on how much traffic your site gets, that may be a better option.
     
    awatson, Apr 21, 2009 IP
  3. JavaScriptBank.com

    JavaScriptBank.com Peon

    Messages:
    141
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #3
    JavaScriptBank.com, Apr 22, 2009 IP