permission denied?

L

laredotornado

Hi,

I'm trying to use the xmlHttpReq object to contact a URL on my server.
But I'm getting a JS "Permission denied" error at the indicated line.
What does it mean and how can I get around it?

function signUp(signUpElt) {
if (!ValidEmail(signUpElt.value)) {
alert("Please enter a valid email address.");
return;
} // if

var xmlHttpReq = false;
var self = this;
// Mozilla/Safari
if (window.XMLHttpRequest) {
self.xmlHttpReq = new XMLHttpRequest();
}
// IE
else if (window.ActiveXObject) {
self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
}
var strURL =
"http://mydomain.myhost.com/add_email_response.php?EmailP=" +
escape(signUpElt.value);
self.xmlHttpReq.open('GET', strURL, true); // throws
"Permission denied" JS error.


Thanks for any help, - Dave
 
A

ASM

(e-mail address removed) a écrit :
Hi,

I'm trying to use the xmlHttpReq object to contact a URL on my server.
But I'm getting a JS "Permission denied" error at the indicated line.
What does it mean

do you request to same domain your file is ?

if not : you can't do that -> permission denied !

if yes :
what does do this 'self' in :
self.xmlHttpReq.open(
what do you expect ?

xmlHttpReq.open() open connexion to desired file (not much more)

then, latter, on server's answer you'll treat the responseText



var http_request;

function signUp(signUpElt) {
if (!ValidEmail(signUpElt.value)) {
alert("Please enter a valid email address.");
return;
}
http_request = false;
// Mozilla/Safari
if (window.XMLHttpRequest) {
http_request = new XMLHttpRequest();
}
// IE
else if (window.ActiveXObject) {
http_request = new ActiveXObject("Microsoft.XMLHTTP");
}
var strURL="http://mydomain.myhost.com/add_email_response.php?EmailP="+
escape(signUpElt.value);
http_request.onreadystatechange = function() { showContents(strURL) };
http_request.open('GET', strURL, true);
http_request.send(null);
}

function showContents(url) {
if (http_request.readyState == 4) {
if (http_request.status == 200) {
var req_content = http_request.responseText;
document.getElementById('content').innerHTML = req_content;
}
else {
alert('Something wrong with this request.');
if(confirm('Do I try to open the new page?'))
location.href=url;
}
}
}
 

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

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,024
Latest member
ARDU_PROgrammER

Latest Threads

Top