0

Dear Friends,

I'm developing a website that can show online users, When ever a user logged we can update the status to "Online" On our database. Now i'm using AJAX.

Is it possible to show the online users without refreshing a page ? That means timed interval for a ajax function.

Checking database for online users every secound using ajax or javascript ? like facebook and gmail. Please help me.

Thanks in advance.

3
Contributors
5
Replies
6
Views
5 Years
Discussion Span
Last Post by rayidi
0
<html>
<head>
<script type="text/javascript">
function timeMsg()
{
var t=setTimeout("alertMsg()",3000);
}
function alertMsg()
{
alert("Hello");
}
</script>
</head>

<body>
<form>
<input type="button" value="Display alert box in 3 seconds"
onclick="timeMsg()" />
</form>
</body>
</html>

Dear makman99,

Thanks for the reply.. but there he used onClick function on a input device. But here i need automatically refresh a div with ajax. That means Its check every time to database and display online friends. I think u got this..

0

First you create a action page in php which will return you latest info you want to display.
I mean I guess you know using ajax or jquery to post and retrive data.

Now You call that ajax/jquery function using timer

jquery tutorial u may find here
http://phpacademy.org/videos/index.php?all

Edited by urtrivedi: n/a

0

krish, those links were examples. You merely need to replace on_click functions with on_load

<body onLoad="StartUpdate()">
<script>
function UpdateOnlineUsers()
{
...
}

function StartUpdate()
{
setInterval("UpdateOnlineUsers()",1000); //Updates online users every second
}
</script>


...
</body>

Edited by makman99: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.