XMLHttpRequest cannot load Cross origin requests are only supported for HTTP

exception 101 was found when retrieving data from an XML file: XMLHttpRequest cannot load the file: /// C: /Users/zaid/Desktop/xml/cd_catalog.xml. Cross-start requests are only supported for HTTP.

<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","xml/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>
+5
source share
1 answer

You are trying to request a resource through your local computer, this is a cross reference. You need access to this resource through your HTTP server in order to access it.

+8
source

All Articles