<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
<script language="javascript">
$(document).ready(function(){
var Initialization = function(){
$('#show').attr('disabled', true);
}
$('#update').bind(
'click',
function(e){
var url = 'Server.php';
$.ajax({
url:url,
type:'POST',
dataType:'json',
success:function(response){
$('#show').attr('disabled', false);
alert('Server Update Success!!');
},
error:function(xhr){
alert('Server Update Failuere!!');
}
});
}
);
$('#show').bind(
'click',
function(e){
var url = 'Client.php';
var mode = 'getAllUser';
$.ajax({
url:url,
type:'POST',
dataType:'json',
data:{
url:url,
mode:mode
},
success:function(response){
var mode = 'checkUsers';
var users = '';
if(!response['responseStatus']){
return false;
}
for(var i = 0; i < response['responseText']['users'].length; i++){
if(i + 1 < response['responseText']['users'].length){
users += response['responseText']['users'][i] + ',';
}else{
users += response['responseText']['users'][i];
}
}
$.ajax({
url:url,
type:'POST',
dataType:'json',
data:{
url:url,
mode:mode,
users:users
},
success:function(response){
var html = '';
if(!response['responseStatus']){
return false;
}
for(var i = 0; i < response['responseText']['online'].length; i++){
html += response['responseText']['users'][i] + (response['responseText']['online'][i] ? ' Online <br />' : ' Offline <br />');
}
$('#message').html(html);
},
error:function(xhr){
alert('Get Data From Server Failure!!!');
}
});
},
error:function(response){
alert('Get Data From Server Failure!!!');
}
});
}
);
Initialization();
});
</script>
<title>User Online</title>
</head>
<body>
<input type="button" id="update" value="Update Server Data" /><br />
<input type="button" id="show" value="Show Online Users" /><br />
<div id="message"></div>
</body>
</html>
|