PDA

View Full Version : Resolved execute process every 10 seconds with AJAX


auriaks
03-11-2010, 12:20 PM
Hi, how to make this script to execute tb_online.php every 10 seconds without refreshing the page?

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript">
function example_ajax_request_go(page){
$('#example-placeholder').load(page);
}
<!--
// Get the HTTP Object
function getHTTPObject(){
if (window.ActiveXObject) return new ActiveXObject("Microsoft.XMLHTTP");
else if (window.XMLHttpRequest) return new XMLHttpRequest();
else {
alert("Jūsų naršyklė nepalaiko AJAX scripto.");
return null;
}
}

// Change the value of the outputText field
function setOutput(){
if(httpObject.readyState == 4){
document.getElementById("msg").innerHTML = httpObject.responseText;
}

}

// Implement business logic
function vykdyti(){
httpObject = getHTTPObject();
if (httpObject != null) {
httpObject.open("GET", "content/tables/tb_online.php?action=online", true);
httpObject.send(null);
httpObject.onreadystatechange = setOutput;
}
}
var httpObject = null;

</script>


<div id="msg" ></div>


Thanks.

auriaks
03-11-2010, 08:01 PM
is this even possible??

the main idea is to make a php script which with ajax would check the online users every 10 seconds :)