topical media & game development
professional-ria-04-HelloWorldv2.htm / htm
<!--
Second version of HelloWorld.html
This version adds:
- javascript function - handleCountryChange() - called when
select is modified. Creates an asynchronous call.
- javascript function - helloCallback() - callback invoked after
the request is handled. Initial implementation just displays an alert.
-->
<html>
<head>
<script type="text/javascript">
var xmlRequest = new XMLHttpRequest();
function handleCountryChange() {
var countryValue = document.getElementById("country").value;
var uri = "helloFiles/" + countryValue + ".txt";
xmlRequest.open("GET", uri, true);
xmlRequest.onreadystatechange = helloCallback;
xmlRequest.send(null);
}
function helloCallback() {
if (xmlRequest.readyState == 4) {
alert("Hello callback was invoked!");
}
}
</script>
</head>
<body>
<form id="helloForm"><label>Say Hello: </label>
<select id="country" onkeyup="handleCountryChange()"
onchange="handleCountryChange()">
<option>France</option>
<option>Germany</option>
<option>Spain</option>
<option>USA</option>
</select>
</form>
<p/>
<label id="messageLabel" style="border: thin solid"></label>
</body>
</html>
(C) Æliens
20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.