Jump to content

xmlhttp.open Access denied.


Recommended Posts

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

Edited by madsovenielsen
Link to comment
Share on other sites

  • 9 months later...
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...