I'm trying to do the simplest example of an XMLHttpRequest take straight from a tutorial. I have an XML file note.xml
<?xml version="1.0" encoding="utf-8" ?>
<note>
<to>Jimmy</to>
<from>Paul</from>
<body>Hello!</body>
</note>
and a html with javascript
<!DOCTYPE html>
<html>
<body>
<h1>W3Schools Internal Note</h1>
<div>
<b>To:</b> <span id="to"></span><br>
<b>From:</b> <span id="from"></span><br>
<b>Message:</b> <span id="message"></span>
</div>
<script>
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("GET","note.xml",false);
xmlhttp.send();
xmlDoc=xmlhttp.responseXML;
document.getElementById("to").innerHTML=
xmlDoc.getElementsByTagName("to")[0].childNodes[0].nodeValue;
document.getElementById("from").innerHTML=
xmlDoc.getElementsByTagName("from")[0].childNodes[0].nodeValue;
document.getElementById("message").innerHTML=
xmlDoc.getElementsByTagName("body")[0].childNodes[0].nodeValue;
</script>
</body>
</html>
As you can see this is taken straight from W3schools. I try and open the HTML in chrome or IE explorer and I get nothing but...
W3Schools Internal Note
To: From: Message:
Nothing populated...What simple thing am I missing. Both files are stored in the same local directory.
Thanks