First Draft
First Draft of the Example Files
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
<script>
|
||||
function asyncRequest()
|
||||
{
|
||||
try // Non IE Browser?
|
||||
{ // Yes
|
||||
var request = new XMLHttpRequest()
|
||||
}
|
||||
catch(e1)
|
||||
{
|
||||
try // IE 6+?
|
||||
{ // Yes
|
||||
request = new ActiveXObject("Msxml2.XMLHTTP")
|
||||
}
|
||||
catch(e2)
|
||||
{
|
||||
try // IE 5?
|
||||
{ // Yes
|
||||
request = new ActiveXObject("Microsoft.XMLHTTP")
|
||||
}
|
||||
catch(e3) // There is no asynchronous support
|
||||
{
|
||||
request = false
|
||||
}
|
||||
}
|
||||
}
|
||||
return request
|
||||
}
|
||||
</script>
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
<!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>
|
||||
params = "url=news.com"
|
||||
request = new asyncRequest()
|
||||
|
||||
request.open("POST", "urlpost.php", true)
|
||||
request.setRequestHeader("Content-type",
|
||||
"application/x-www-form-urlencoded")
|
||||
|
||||
request.onreadystatechange = function()
|
||||
{
|
||||
if (this.readyState == 4)
|
||||
{
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
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>
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php // urlpost.php
|
||||
if (isset($_POST['url']))
|
||||
{
|
||||
echo file_get_contents('http://' . SanitizeString($_POST['url']));
|
||||
}
|
||||
|
||||
function SanitizeString($var)
|
||||
{
|
||||
$var = strip_tags($var);
|
||||
$var = htmlentities($var);
|
||||
return stripslashes($var);
|
||||
}
|
||||
?>
|
||||
+62
@@ -0,0 +1,62 @@
|
||||
<!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>
|
||||
nocache = "&nocache=" + Math.random() * 1000000
|
||||
request = new asyncRequest()
|
||||
request.open("GET", "urlget.php?url=news.com" + nocache, true)
|
||||
|
||||
request.onreadystatechange = function()
|
||||
{
|
||||
if (this.readyState == 4)
|
||||
{
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
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>
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php // urlget.php
|
||||
if (isset($_GET['url']))
|
||||
{
|
||||
echo file_get_contents("http://".sanitizeString($_GET['url']));
|
||||
}
|
||||
|
||||
function sanitizeString($var)
|
||||
{
|
||||
$var = strip_tags($var);
|
||||
$var = htmlentities($var);
|
||||
return stripslashes($var);
|
||||
}
|
||||
?>
|
||||
@@ -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);
|
||||
}
|
||||
?>
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
<!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>
|
||||
nocache = "&nocache=" + Math.random() * 1000000
|
||||
url = "rss.news.yahoo.com/rss/topstories"
|
||||
out = "";
|
||||
|
||||
request = new asyncRequest()
|
||||
request.open("GET", "xmlget.php?url=" + url + nocache, true)
|
||||
|
||||
request.onreadystatechange = function()
|
||||
{
|
||||
if (this.readyState == 4)
|
||||
{
|
||||
if (this.status == 200)
|
||||
{
|
||||
if (this.responseText != null)
|
||||
{
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
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>
|
||||
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<rss version="2.0">
|
||||
<channel>
|
||||
<title>RSS Feed</title>
|
||||
<link>http://website.com</link>
|
||||
<description>website.com's RSS Feed</description>
|
||||
<pubDate>Mon, 11 May 2020 00:00:00 GMT</pubDate>
|
||||
<item>
|
||||
<title>Headline</title>
|
||||
<guid>http://website.com/headline</guid>
|
||||
<description>This is a headline</description>
|
||||
</item>
|
||||
<item>
|
||||
<title>Headline 2</title>
|
||||
<guid>http://website.com/headline2</guid>
|
||||
<description>The 2nd headline</description>
|
||||
</item>
|
||||
</channel>
|
||||
</rss>
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php // urlget.php
|
||||
|
||||
if (isset($_GET['url']))
|
||||
{
|
||||
echo file_get_contents("http://" . sanitizeString($_GET['url']));
|
||||
}
|
||||
|
||||
function sanitizeString($var)
|
||||
{
|
||||
$var = strip_tags($var);
|
||||
$var = htmlentities($var);
|
||||
return stripslashes($var);
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php // urlpost.php
|
||||
if (isset($_POST['url']))
|
||||
{
|
||||
echo file_get_contents("http://" . SanitizeString($_POST['url']));
|
||||
}
|
||||
|
||||
function SanitizeString($var)
|
||||
{
|
||||
$var = strip_tags($var);
|
||||
$var = htmlentities($var);
|
||||
return stripslashes($var);
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user