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;
}
}
}