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 post
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 post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...