www.webdeveloper.com
Results 1 to 7 of 7

Thread: "Access to restricted URI denied"

  1. #1
    Join Date
    Nov 2007
    Posts
    194

    "Access to restricted URI denied"

    Hi everyone, i've been working on a project here of late, and I took a break from it and came back to it today. It's a fairly simple AJAX script but now i'm getting two errors

    Error: uncaught exception: [Exception... "Access to restricted URI denied" code: "1012" nsresult: "0x805303f4 (NS_ERROR_DOM_BAD_URI)" location: "box.js Line: 28"]

    and

    Security Error: Content at http://www.recorded-live.com/fitness/active.php may not load data from http://recorded-live.com/fitness/scripts/recordloader.php.


    I don't know what they mean and I can't find any sort of error around line 28. I was hoping someone could help me:

    Code:
    function preprecords()
    {
    	if(notsaved==true)
    	{
    		var answer=confirm("Save changes to current record?")
    		if(answer)
    		{
    			fromprep=true;
    			saveit();
    		}
    		if(!answer)
    		{
    			runload();
    			notsaved==false
    		}
    	}
    	if(notsaved==false)
    	{
    	runload();
    	}
    }
    function runload()
    {
    	var url = "http://recorded-live.com/fitness/scripts/recordloader.php";
    
    	/* Place "Opening Record" Message here */
    	/* Passing variables lastname and first name to PHP */
    	http.open("GET", url, true);
    	http.onreadystatechange = handleHttpResponseOpen;
    	http.send(null);
    }
    	
    function handleHttpResponseOpen() 
    {
    	if (http.readyState == 4) 
    	{
    		resultsuser = http.responseText;
    		/* On php script completion print script result in response div */
    		if(resultsuser == "") resultsuser = "";
    		document.getElementById('stdname').innerHTML = resultsuser;
    		// evaluate javascript
    		scriptTag='(<script.*?>)((\n|\r|.)*?)(<\/script>)';
    		if (scripts=resultsuser.match(scriptTag)) {
    			// remove slashes
    		 	scripts[2]=scripts[2].replace(/\\/g,"");
    		 	//run scripts
    		 	eval(scripts[2]);
    		}
    	}			
    }
    
    function getHTTPObjectUser() 
    {
    	var xmlhttp;
    	if (!xmlhttp && typeof XMLHttpRequest != 'undefined') 
    	{
    		try {xmlhttp = new XMLHttpRequest();} catch (e) {xmlhttp = false;}
    	}
    	
    //KILL HERE
    //END KILL
    	return xmlhttp;
    }
    var http = getHTTPObjectUser();
    
    
    
    function showBox(){
    document.getElementById("overlay").style.display="block";
    document.getElementById("box").style.display="block";
    }
    
    function hideBox(){
    document.getElementById("overlay").style.display="none";
    document.getElementById("box").style.display="none";
    }

  2. #2
    Join Date
    Aug 2007
    Posts
    3,767
    Take the "www." out of the URI, or add it into the AJAX url.

    You are not allowed to make AJAX requests on another domain, and it thinks that www.google.com and google.com are different domains. The solution is to use relative paths instead.
    Code:
    var url = "./scripts/recordloader.php";
    The ./ isn't really needed, it means present directory, but I find it clearest. scripts/recordloader.php will do as well.

  3. #3
    Join Date
    Nov 2007
    Posts
    194
    That did it! Thanks! I'm very curious why it was working last week and not now because i did not change that since then

  4. #4
    Join Date
    Aug 2007
    Posts
    3,767
    Were you going to the site without the www maybe?

  5. #5
    Join Date
    Jan 2009
    Posts
    1
    Hi,

    This is an old thread, but the problem was new for me... I spent a couple of hours banging my head against it, so: many thanks!

  6. #6
    Join Date
    Mar 2009
    Location
    Uzbekistan
    Posts
    4
    Quote Originally Posted by cfgcjm View Post
    That did it! Thanks! I'm very curious why it was working last week and not now because i did not change that since then
    Also it seems that older versions of Firefox did not have this security constraints. So your javascript would have worked in those versions.

    Quote Originally Posted by chrr
    Hi,

    This is an old thread, but the problem was new for me... I spent a couple of hours banging my head against it, so: many thanks!
    I also came across this problem and found this article very useful.

  7. #7
    Join Date
    Jan 2010
    Posts
    3

    Solution: Access to restricted URI denied" code: "1012

    At times I have come across "Access to restricted URI denied" code: "1012 even when making a legitimate AJAX call but from a different directory/site level. I know this is a security feature to restrict cross domain AJAX call. But firefox throws this error when calling a file in the same domain also (but not always).

    Thanks
    Eliza

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles