Update test.html
This commit is contained in:
@@ -1,46 +1,37 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<style>
|
<head>
|
||||||
table,th,td {
|
<meta http-equiv="Cache-Control" content="must-revalidate, no-store, no-cache">
|
||||||
border : 1px solid black;
|
<title>Test Document</title>
|
||||||
border-collapse: collapse;
|
<link href="https://fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet">
|
||||||
|
<link rel="stylesheet" type="text/css" href="../app/stylesheet.css">
|
||||||
|
#demo {
|
||||||
|
width: 1200px;
|
||||||
|
margin: 9px auto;
|
||||||
|
border: 2px solid blue;
|
||||||
}
|
}
|
||||||
th,td {
|
</head>
|
||||||
padding: 5px;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<h2>The XMLHttpRequest Object</h2>
|
<h2>The XMLHttpRequest Object</h2>
|
||||||
|
|
||||||
<button type="button" onclick="loadDoc()">Get my CD collection</button>
|
<button type="button" onclick="loadHTML()">Get LinkBoard</button>
|
||||||
<br><br>
|
<br><br>
|
||||||
<table id="demo"></table>
|
<div id="demo"></div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
function loadDoc() {
|
function loadHTML() {
|
||||||
var xhttp = new XMLHttpRequest();
|
var http = new XMLHttpRequest();
|
||||||
xhttp.onreadystatechange = function() {
|
http.onreadystatechange = function() {
|
||||||
if (this.readyState == 4 && this.status == 200) {
|
if (this.readyState == 4 && this.status == 200) {
|
||||||
myFunction(this);
|
myFunction(this);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
xhttp.open("GET", "cd_catalog.xml", true);
|
http.open("GET", "cd_catalog.xml", true);
|
||||||
xhttp.send();
|
http.send();
|
||||||
}
|
}
|
||||||
function myFunction(xml) {
|
function myFunction(data) {
|
||||||
var i;
|
document.getElementById("demo").innerHTML = data.responseText;
|
||||||
var xmlDoc = xml.responseXML;
|
|
||||||
var table="<tr><th>Artist</th><th>Title</th></tr>";
|
|
||||||
var x = xmlDoc.getElementsByTagName("CD");
|
|
||||||
for (i = 0; i <x.length; i++) {
|
|
||||||
table += "<tr><td>" +
|
|
||||||
x[i].getElementsByTagName("ARTIST")[0].childNodes[0].nodeValue +
|
|
||||||
"</td><td>" +
|
|
||||||
x[i].getElementsByTagName("TITLE")[0].childNodes[0].nodeValue +
|
|
||||||
"</td></tr>";
|
|
||||||
}
|
|
||||||
document.getElementById("demo").innerHTML = table;
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user