~/public_html/demo/AJAX/index.html
|
|
<!DOCTYPE html>
<html>
<head>
<title>Our Class</title>
<link href="Site.css" rel="stylesheet">
</head>
<body>
<nav id="nav01"></nav>
<div id="main">
<h1>Welcome to Our Class</h1>
<h3>Web Site Main Ingredients:</h3>
<p>Pages (HTML)</p>
<p>Style Sheets (CSS)</p>
<p>Computer Code (JavaScript)</p>
<p>Live Data (Files and Databases)</p>
<footer id="foot01"></footer>
</div>
<script src="Script.js"></script>
</body>
</html>
|
~/public_html/demo/AJAX/Student.html
|
|
<!DOCTYPE html>
<html>
<head>
<title>Our Class</title>
<link href="Site.css" rel="stylesheet">
</head>
<body>
<nav id="nav01"></nav>
<div id="main">
<h1>Students</h1>
<div id="id01"></div>
<footer id="foot01"></footer>
</div>
<script src="Script.js"></script>
<script>
var xmlhttp = new XMLHttpRequest( );
var url = "StudentMySQL.php";
xmlhttp.onreadystatechange = function( ) {
if ( xmlhttp.readyState == 4 && xmlhttp.status == 200 ) {
myFunction( xmlhttp.responseText );
}
}
xmlhttp.open( "GET", url, true );
xmlhttp.send( );
function myFunction( response ) {
var arr = JSON.parse( response );
var i;
var out = "<table><tr><th>Name</th>" +
"<th>City</th>" +
"<th>Country</th></tr>";
for ( i = 0; i < arr.length; i++ ) {
out += "<tr><td>" + arr[i].Name +
"</td><td>" + arr[i].City +
"</td><td>" + arr[i].Country +
"</td></tr>";
}
out += "</table>"
document.getElementById( "id01" ).innerHTML = out;
}
</script>
</body>
</html>
|
~/public_html/demo/AJAX/About.html
|
|
<!DOCTYPE html>
<html>
<head>
<title>About</title>
<link href="Site.css" rel="stylesheet">
</head>
<body>
<nav id="nav01"></nav>
<div id="main">
<h1>About Us</h1>
<p>Department of Computer Science, UND</p>
<footer id="foot01"></footer>
</div>
<script src="Script.js"></script>
</body>
</html>
|