topical media & game development
basic-ajax-11-ch11-examp3.htm / htm
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>My Array</title>
<script type="text/javascript">
function myRequest()
{
var request = false;
if (window.XMLHttpRequest) {
request = new XMLHttpRequest();
}
else if (window.ActiveXObject) {
request = new ActiveXObject("Microsoft.XMLHTTP");
}
if (window.overrideMimeType) {
request.overrideMimeType("text/xml");
}
if(request) {
request.open("GET", <array.php>, true);
request.onreadystatechange = function()
{
if ((request.readyState == 4) && (request.status == 200)) {
var jsonResp = request.responseText;
jsonResp = eval("(" + jsonResp + ")");
var display1 = document.getElementById('display');
display1.innerHTML = jsonResp;
}
}
request.send(null);
}
}
</script>
</head>
<body onload="myRequest()">
<div id="display"></div>
</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.