Errata amendments

This commit is contained in:
RobinNixon
2021-11-16 12:23:58 +00:00
parent eeb4267820
commit fc6b9f4df3
11 changed files with 27 additions and 59 deletions
+35
View File
@@ -0,0 +1,35 @@
<!DOCTYPE html>
<html> <!-- xmlget.html -->
<head>
<title>Asynchronous Communication Example</title>
</head>
<body>
<h1>Loading XML data into a DIV</h1>
<div id='info'>This sentence will be replaced</div>
<script>
let out = ''
let nocache = "&nocache=" + Math.random() * 1000000
let url = "rss.news.yahoo.com/rss/topstories"
let XHR = new XMLHttpRequest()
XHR.open("POST", "http://127.0.0.1/18/xmlget.php?url=" + url + nocache, true)
XHR.setRequestHeader("Content-type", "application/x-www-form-urlencoded")
XHR.send()
XHR.onreadystatechange = function()
{
if (this.readyState == 4 && this.status == 200)
{
let titles = this.responseXML.getElementsByTagName('title')
for (let j = 0 ; j < titles.length ; ++j)
{
out += titles[j].childNodes[0].nodeValue + '<br>'
}
document.getElementById('info').innerHTML = out
}
}
</script>
</body>
</html>