Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: "Access to restricted URI denied"

Access to restricted URI denied" code: "1012 [Break On This Error]

xhttp.send(null);

function getXML(xml_file) {
  
  if (window.XMLHttpRequest) {
    
    var xhttp = new XMLHttpRequest();  // Cretes a instantce of XMLHttpRequest object
  }
  else {
    
    var xhttp = new ActiveXObject("Microsoft.XMLHTTP");  // for IE 5/6
  }
  
  xhttp.open("GET",xml_file,false);  
  xhttp.send(null);  
  
   var xmlDoc = xhttp.responseXML; 
 
   return (xmlDoc);
}

I'm trying to get data from a XML file using JavaScript. Im using Firebug to test and debug on Firefox.

The above error is what I'm getting. It works in other places i used the same before, why is acting weird here?

Can someone help me why it's occuring?

Update:

http://jquery-howto.blogspot.com/2008/12/access-to-restricted-uri-denied-code.html

I found this link explaining the cause of the problem. But I didn't get what the solution given means can someone elaborate?

like image 682
Bala Avatar asked Jul 11 '11 17:07

Bala


1 Answers

Another possible cause of this is when you are working with a .html file directly on the file system. For example, if you're accessing it using this url in your browser: C:/Users/Someguy/Desktop/MyProject/index.html

If that then has to make an ajax request, the ajax request will fail because ajax requests to the filesystem are restricted. To fix this, setup a webserver that points localhost to C:/Users/Someguy/Desktop/MyProject and access it from http://localhost/index.html

like image 154
Kevin B Avatar answered Oct 02 '22 13:10

Kevin B