Forum Moderators: open
/**
* Gets an XMLHttpRequest. For Internet Explorer 6, attempts to use MXSML 3.0.
* @return {XMLHttpRequest or equivalent ActiveXObject}
*/
function getXHR() {
return window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject('MSXML2.XMLHTTP.3.0');
}
var nocache = '&nocache=' + Math.random() * 1000000,
url = 'rss.news.yahoo.com/rss/topstories',
request = getXHR();
/**
* Gets an XMLHttpRequest. For Internet Explorer 6, attempts to use MXSML 3.0.
* @return {XMLHttpRequest or equivalent ActiveXObject}
*/
function getXHR() {
return window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject('MSXML2.XMLHTTP.3.0');
}
request.open('GET', 'xmlget.php?url=' + url + nocache, true);
request.onreadystatechange = function () {
var j,
out = '',
titles;
if (this.readyState == 4) {
if (this.status == 200) {
if (this.responseXML != 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('Ajax error: No data received');
}
}
else {
alert('Ajax error :'+ this.statusText);
}
}
}
request.send(null)
<title>Ajax XML Example<title>
You are so going to kick yourself
file_get_contents('http://'.sanitizeString($_GET['url']));
echo file_get_contents('http://'.sanitizeString($_GET['url']));
<h2>Loading a XML content into a DIV</h2>:-)