madsovenielsen Posted July 2, 2010 Share Posted July 2, 2010 Hey all.I have taken this JavaScript directly from w3schools.com <html><body><script type="text/javascript">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","cd_catalog.xml",false);xmlhttp.send();xmlDoc=xmlhttp.responseXML; document.write("<table border='1'>");var x=xmlDoc.getElementsByTagName("CD");for (i=0;i<x.length;i++) { document.write("<tr><td>"); document.write(x[i].getElementsByTagName("ARTIST")[0].childNodes[0].nodeValue); document.write("</td><td>"); document.write(x[i].getElementsByTagName("TITLE")[0].childNodes[0].nodeValue); document.write("</td></tr>"); }document.write("</table>");</script></body></html> I have the correct xml file stored localy on my computer. in the same place as my html page with the scriptbut im getting access denied on line 13. i have read that this shouldt only happen if the xml file and the script is in 2 different domains. Whats wrong ?/mads Link to comment Share on other sites More sharing options...
madsovenielsen Posted July 2, 2010 Author Share Posted July 2, 2010 Nevermind. the files have to reside on a web server. and be served over HTTP.my big mistake Link to comment Share on other sites More sharing options...
LaRK Posted April 28, 2011 Share Posted April 28, 2011 Nevermind. the files have to reside on a web server. and be served over HTTP.my big mistake Thank you, mads, for sharing your experience. I did essentially the exact same experiment, and I don't know how long it would have taken me to figure out that it had to be served over HTTP. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.