Update test.html

This commit is contained in:
vkservicesllc
2018-11-07 09:07:22 -05:00
committed by GitHub
parent ec86ccd956
commit 658c70d720

View File

@@ -1,46 +1,37 @@
<!DOCTYPE html>
<html>
<style>
table,th,td {
border : 1px solid black;
border-collapse: collapse;
}
th,td {
padding: 5px;
}
</style>
<head>
<meta http-equiv="Cache-Control" content="must-revalidate, no-store, no-cache">
<title>Test Document</title>
<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;
}
</head>
<body>
<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>
<table id="demo"></table>
<div id="demo"></div>
<script>
function loadDoc() {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
function loadHTML() {
var http = new XMLHttpRequest();
http.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
myFunction(this);
}
};
xhttp.open("GET", "cd_catalog.xml", true);
xhttp.send();
http.open("GET", "cd_catalog.xml", true);
http.send();
}
function myFunction(xml) {
var i;
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;
function myFunction(data) {
document.getElementById("demo").innerHTML = data.responseText;
}
</script>