/    Sign up×
Community /Pin to ProfileBookmark

"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”;
}[/CODE]

to post a comment
JavaScript

6 Comments(s)

Copy linkTweet thisAlerts:
@Declan1991Jul 24.2008 — 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.var url = "[color=red][b]./[/b][/color]scripts/recordloader.php";
The [b]./[/b] isn't really needed, it means present directory, but I find it clearest. [b]scripts/recordloader.php[/b] will do as well.
Copy linkTweet thisAlerts:
@cfgcjmauthorJul 24.2008 — 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
Copy linkTweet thisAlerts:
@Declan1991Jul 24.2008 — Were you going to the site without the www maybe?
Copy linkTweet thisAlerts:
@chrrJan 19.2009 — 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!
Copy linkTweet thisAlerts:
@UzbekjonMar 02.2009 — 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[/QUOTE]
Also it seems that older versions of Firefox did not have this security constraints. So your javascript would have worked in those versions.

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![/QUOTE]

I also came across this problem and found this article very useful.
Copy linkTweet thisAlerts:
@eliza81Feb 02.2010 — 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
×

Success!

Help @cfgcjm spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.28,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...