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";
}
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.
Great wit and madness are near allied, and fine a line their bounds divide.
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).
Bookmarks