Updated files

This commit is contained in:
RobinNixon
2021-04-18 11:18:28 +01:00
parent aefe77f6e8
commit f63a81074d
187 changed files with 1694 additions and 254 deletions
+8 -47
View File
@@ -8,58 +8,19 @@
<div id='info'>This sentence will be replaced</div>
<script>
params = "url=news.com"
request = new asyncRequest()
let XHR = new XMLHttpRequest()
request.open("POST", "urlpost.php", true)
request.setRequestHeader("Content-type",
"application/x-www-form-urlencoded")
XHR.open("POST", "http://127.0.0.1/18/urlpost.php", true)
XHR.setRequestHeader("Content-type", "application/x-www-form-urlencoded")
XHR.send("url=news.com")
request.onreadystatechange = function()
XHR.onreadystatechange = function()
{
if (this.readyState == 4)
if (this.readyState == 4 && this.status == 200)
{
if (this.status == 200)
{
if (this.responseText != null)
{
document.getElementById('info').innerHTML =
this.responseText
}
else alert("Communication error: No data received")
}
else alert( "Communication error: " + this.statusText)
document.getElementById("info").innerHTML = this.responseText
}
}
request.send(params)
function asyncRequest()
{
try
{
var request = new XMLHttpRequest()
}
catch(e1)
{
try
{
request = new ActiveXObject("Msxml2.XMLHTTP")
}
catch(e2)
{
try
{
request = new ActiveXObject("Microsoft.XMLHTTP")
}
catch(e3)
{
request = false
}
}
}
return request
}
}
</script>
</body>
</html>
+10 -45
View File
@@ -8,55 +8,20 @@
<div id='info'>This sentence will be replaced</div>
<script>
nocache = "&nocache=" + Math.random() * 1000000
request = new asyncRequest()
request.open("GET", "urlget.php?url=news.com" + nocache, true)
let nocache = "&nocache=" + Math.random() * 1000000
let XHR = new XMLHttpRequest()
request.onreadystatechange = function()
XHR.open("POST", "http://127.0.0.1/18/urlget.php?url=news.com" + nocache, true)
XHR.setRequestHeader("Content-type", "application/x-www-form-urlencoded")
XHR.send()
XHR.onreadystatechange = function()
{
if (this.readyState == 4)
if (this.readyState == 4 && this.status == 200)
{
if (this.status == 200)
{
if (this.responseText != null)
{
document.getElementById('info').innerHTML =
this.responseText
}
else alert("Communication error: No data received")
}
else alert( "Communication error: " + this.statusText)
document.getElementById("info").innerHTML = this.responseText
}
}
request.send(null)
function asyncRequest()
{
try
{
var request = new XMLHttpRequest()
}
catch(e1)
{
try
{
request = new ActiveXObject("Msxml2.XMLHTTP")
}
catch(e2)
{
try
{
request = new ActiveXObject("Microsoft.XMLHTTP")
}
catch(e3)
{
request = false
}
}
}
return request
}
}
</script>
</body>
</html>
+17 -52
View File
@@ -8,63 +8,28 @@
<div id='info'>This sentence will be replaced</div>
<script>
nocache = "&nocache=" + Math.random() * 1000000
url = "rss.news.yahoo.com/rss/topstories"
out = "";
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()
request = new asyncRequest()
request.open("GET", "xmlget.php?url=" + url + nocache, true)
request.onreadystatechange = function()
XHR.onreadystatechange = function()
{
if (this.readyState == 4)
if (this.readyState == 4 && this.status == 200)
{
if (this.status == 200)
{
if (this.responseText != null)
{
titles = this.responseXML.getElementsByTagName('title')
let titles = this.responseXML.getElementsByTagName('title')
for (j = 0 ; j < titles.length ; ++j)
{
out += titles[j].childNodes[0].nodeValue + '<br>'
}
document.getElementById('info').innerHTML = out
}
else alert("Communication error: No data received")
}
else alert( "Communication error: " + this.statusText)
for (let j = 0 ; j < titles.length ; ++j)
{
out += titles[j].childNodes[0].nodeValue + '<br>'
}
document.getElementById('info').innerHTML = out
}
}
request.send(null)
function asyncRequest()
{
try
{
var request = new XMLHttpRequest()
}
catch(e1)
{
try
{
request = new ActiveXObject("Msxml2.XMLHTTP")
}
catch(e2)
{
try
{
request = new ActiveXObject("Microsoft.XMLHTTP")
}
catch(e3)
{
request = false
}
}
}
return request
}
}
</script>
</body>
</html>
+27
View File
@@ -0,0 +1,27 @@
<!DOCTYPE html>
<html> <!-- urlget.html -->
<head>
<title>Asynchronous Communication Example</title>
</head>
<body style='text-align:center'>
<h1>Loading a web page into a DIV</h1>
<div id='info'>This sentence will be replaced</div>
<script>
let nocache = "&nocache=" + Math.random() * 1000000
let XHR = new XMLHttpRequest()
XHR.open("POST", "http://127.0.0.1/18/urlget.php?url=news.com" + nocache, true)
XHR.setRequestHeader("Content-type", "application/x-www-form-urlencoded")
XHR.send()
XHR.onreadystatechange = function()
{
if (this.readyState == 4 && this.status == 200)
{
document.getElementById("info").innerHTML = this.responseText
}
}
</script>
</body>
</html>
+26
View File
@@ -0,0 +1,26 @@
<!DOCTYPE html>
<html> <!-- urlpost.html -->
<head>
<title>Asynchronous Communication Example</title>
</head>
<body style='text-align:center'>
<h1>Loading a web page into a DIV</h1>
<div id='info'>This sentence will be replaced</div>
<script>
let XHR = new XMLHttpRequest()
XHR.open("POST", "http://127.0.0.1/18/urlpost.php", true)
XHR.setRequestHeader("Content-type", "application/x-www-form-urlencoded")
XHR.send("url=news.com")
XHR.onreadystatechange = function()
{
if (this.readyState == 4 && this.status == 200)
{
document.getElementById("info").innerHTML = this.responseText
}
}
</script>
</body>
</html>
+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>
+14
View File
@@ -0,0 +1,14 @@
<?php // xmlget.php
if (isset($_GET['url']))
{
header('Content-Type: text/xml');
echo file_get_contents("http://".sanitizeString($_GET['url']));
}
function sanitizeString($var)
{
$var = strip_tags($var);
$var = htmlentities($var);
return stripslashes($var);
}
?>