Getting "Access to Restricted URI denied" error, but not using Cross-Domain??
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: Getting "Access to Restricted URI denied" error, but not using Cross-Domain??

  1. #1
    Join Date
    May 2009
    Posts
    3

    Getting "Access to Restricted URI denied" error, but not using Cross-Domain??

    I'm creating an web mapping application with AJAX functionality. I'm also a little new to the use of AJAX so this is my first time using this.

    So I retrieve an XML file through my own web server. But the thing is, I'm getting this error message (Error code 1012) on my Error Console on Firefox, even though I'm not using any cross-domain referencing. The application works perfectly fine on IE though.

    I'm not sure if it has to do with the fact that I'm using a port number within the URL for the GET call (see code below).

    Here is a snippet of my javaScript file:

    Code:
    // initialize the XMLHttpRequest object
    if (window.XMLHttpRequest) {
    	// If IE7, Mozilla, Safari, and so on: Use native object.
    	xhr = new XMLHttpRequest();
    } else {
    	if (window.ActiveXObject) {
    		// ...otherwise, use the ActiveX control for IE5.x and IE6.
    		xhr = new ActiveXObject('MSXML2.XMLHTTP.3.0');
    	} else {
    		alert('XMLHttpRequest not supported. Your browser does not support XMLHttpRequest');
    	}
    }
    
    // handle xhr callback
    xhr.onreadystatechange  = function(){ 
    	if(xhr.readyState  == 4) { // if done loading url
    		if(xhr.status  == 200) {// if url is ok
    			myFunctionToHandleResponse(xhr.responseXML);
    		}else {
    			alert('An error occurred. XMLHttpRequest status code: ' + xhr.status);
    		}
    	}
    }
    
    // example URL format I'm using
    url = "http://webfeed.mywebserver.ca:9090/?SERVICE=EXT"
    url+= "&REQUEST=GetWarningInfo&INFO_FORMAT=text/xml
    url+= "&LON=58.446798&LAT=60.654948&TIME=2009-05-11T17:00:00Z"
    url+= "&MOREQUERY=blahblah"
    
    
    // AJAX call
    xhr.open('GET',url, true);
    xhr.send(null);
    My html file is on the same domain as my data feed:
    http://webfeed.mywebserver.ca/folder1/myhtml.html

    The URL returns basically an XML file.

    Anyone have any idea what my issue is? I'm completely stumped on this. Any help would be much appreciated.
    Last edited by kngai; May 11th, 2009 at 07:22 PM.

  2. #2
    PeejAvery's Avatar
    PeejAvery is offline Super Moderator Power Poster
    Join Date
    May 2002
    Posts
    10,879

    Re: Getting "Access to Restricted URI denied" error, but not using Cross-Domain??

    Even though you may be executing this on the same domain, because you supplied the full http://... the browser assumes it is cross-domain. You need to use relative paths when working with AJAX.
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  3. #3
    Join Date
    May 2009
    Posts
    3

    Re: Getting "Access to Restricted URI denied" error, but not using Cross-Domain??

    So what would be the relative path format? I tried doing:
    "../:9090/?SERVICE=EXT&QUERY=blahblah"
    But I don't think it's right. How would you specify a relative path and having to specify the port number into it?

  4. #4
    PeejAvery's Avatar
    PeejAvery is offline Super Moderator Power Poster
    Join Date
    May 2002
    Posts
    10,879

    Re: Getting "Access to Restricted URI denied" error, but not using Cross-Domain??

    You can't with a port number.
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  5. #5
    Join Date
    May 2009
    Posts
    3

    Re: Getting "Access to Restricted URI denied" error, but not using Cross-Domain??

    Well that answers my suspicion about that. Looks like I will have to setup a proxy to get around this.

    Thanks for the help though. Much appreciated.

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center