I suppose I should show you my code..
CLIENT:
<html>
<head>
<title>AJAX in your web page</title>
<style>
#result { background-color: #DDDDFF;}
</style>
<script type=text/javascript language=javascript>
<!-- Hide Javascript on old browsers
var rqo;
function aboutlang(current) {
var lang = current.options[current.selectedIndex].value;
if (lang != ""
{
document.getElementById("result"
.innerHTML =
"Fetching data ... <br /><br /><b>" + lang + "</b>";
rqo = new XMLHttpRequest();
var qs = encodeURIComponent(lang);
var qry = "index.php?towhich=" + qs;
rqo.open('GET',qry,true);
rqo.send(null);
rqo.onreadystatechange = handlelang;
}
return false;
}
function handlelang() {
document.getElementById("result"
.innerHTML =
rqo.responseText + " (via Ajax)";
}
-->
</script>
</head>
<body>
<h1>Ajax demonstration - Asynchronous Javascript and XML</h1>
The selection box on this page calls up a server side program
(an application server / content provider / web service) and
displays elements of the result in the changeable area of the page
<hr />
<form>Please select a programming language
<select onChange="aboutlang(this)">
<option value="None">------</option>
<option value="Perl">Perl</option>
<option value="PHP">PHP</option>
<option value="Python">Python</option>
</select>
<input type="submit" value="Reload page / Reset"/>
</form>
SERVER:
<?php
/* Ajax Demonstration - takes "towhich" parameter and looks up
that string in an array of possible responses */
$responses = array(
"Perl" => "Perl was written by Larry Wall",
"PHP" => "Rasmus Lerdorf wrote PHP",
"Python" => "From Guido van Rossum came Python"
;
$send = $responses[$_REQUEST[towhich]];
if ($send == ""
{
$send = " --- No information available --- ";
}
$send = "Data retrieved from server at ".date("H:i:s"
.
" server time<br /><br />"."<b>$send</b>";
print ($send);
?>
Any ideas..?