"Permission denied" for XMLHttpRequest in Firefox

D

dx27s

Hi all,

I'm working with the XMLHttpRequest object. I receive the following
error message: "Permission denied to call method XMLHttpRequest.open"

This occurs in Firefox only. IE works fine.

From my research so far, it seems like this is a security issue related
to the fact that I am trying to access a url on a second server. Both
servers are under my control, however. Is there a way to get around this
limitation?


CODE SNIPPETS:

function getPage() {
waiting = true;
try {
loadPage('<%=testURL%>'); // generated by JSP code
} catch(e) {
var msg = (typeof e == "string") ? e : ((e.message) ? e.message :
"Unknown Error");
alert("Unable to get XML data:\n" + msg);
return;
}
}

function loadPage(url) {
// branch for native XMLHttpRequest object
if (window.XMLHttpRequest) {
req = new XMLHttpRequest();
req.onreadystatechange = processPage;
req.open("GET", url, true);
req.send(null);
// branch for IE/Windows ActiveX version
} else if (window.ActiveXObject) {
isIE = true;
req = new ActiveXObject("Microsoft.XMLHTTP");
if (req) {
req.onreadystatechange = processPage;
req.open("GET", url, true);
req.send();
}
}
}

function processPage() {
// only if req shows "loaded"
if (req.readyState == 4) {
// only if "OK"
if (req.status == 200) {
// ...processing statements go here...
//stream = req.responseText;
//alert(stream);

location.href = "frames.jsp";

} else {
waiting=false;
}
}
}
 
L

Lance Dyas

dx27s said:
Hi all,

I'm working with the XMLHttpRequest object. I receive the following
error message: "Permission denied to call method XMLHttpRequest.open"

This occurs in Firefox only. IE works fine.

Actually people with default xp sp2 security will also have the problem
in IE
From my research so far, it seems like this is a security issue related
to the fact that I am trying to access a url on a second server. Both
servers are under my control, however. Is there a way to get around this
limitation?


A simple redirector which can be accomplished a number of ways but if
you control both servers and they use Apache I recommend you use
mod_rewrite, so that the request will client side be back to the same
server (but be rewritten server side to reference the second server)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top