Find jobs - Debt Consolidation - Debt Consolidation - Debt Consolidation - Debt Consolidation

PDA

View Full Version : Use Javscript to check user online


imdavidlee
Apr 21st 2009, 2:55 am
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>

awatson
Apr 21st 2009, 2:55 pm
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.

JavaScriptBank.com
Apr 22nd 2009, 11:23 pm
if only JavaScript (http://www.javascriptbank.com/)is nope, sum of online users (http://www.javascriptbank.com/=online users) must processed & calculated & stored at server