You really don't need a plugin so much, just create a page that does nothing but echo the count then call that page on an interval, for example:
function updateCount() {
$('#userCount').load('myCounter.php', function() {
setTimeout(updateCount, 2000);
});
}
$(updateCount); //run on document.ready
This uses .load()
to fetch the count and place it in the #userCount
element (a <span>
or <div>
, whatever it is), wait 2 seconds and do it again. You want to avoid setInterval()
in these cases because the ajax request time is an unknown, and you don't want those to start overlapping. Instead, use setTimeout()
so it runs again 2 seconds (or however often you want) after the request completes.