



























Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




























function ajaxResponse() //This gets called when the readyState changes. { if (ajaxRequest.readyState != 4) // check to see if we're done { return; } else { if (ajaxRequest.status == 200) // check to see if successful { document.getElementById("showtime").innerHTML = ajaxRequest.responseText; } else { alert("Request failed: " + ajaxRequest.statusText); } } }
function getServerTime() // The main JavaScript for calling the update. { ajaxRequest = getXMLHttpRequest(); if (!ajaxRequest) { document.getElementById("showtime").innerHTML = "Request error!"; return; } var myURL = "telltime.php"; var myRand = parseInt(Math.random()*999999999999999); myURL = myURL + "?rand=" + myRand; ajaxRequest.onreadystatechange = ajaxResponse; ajaxRequest.open("GET", myURL); ajaxRequest.send(null); }
Ajax Demonstration
Getting the server time without refreshing the page
'. date('H:i:s'). ""; ?>
'; $td = '';
$table = ''; $table .= $tr. $td. date('j M Y'). ''; $table .= $tr. $td. date('H:i:s'). ''; $table .= ''; echo $table; ?>