The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

Chester (3) [Avatar] Offline
#1
Hello everybody,
I have a problem that I have not been able to find an answer to even after hours of Google searching.

I have a page (I'll call this 'child page', for reasons that will become clear presently) that contains a button that, when pressed, makes an asynchronous request to the server. The request goes through, and a response comes back. It works without a glitch. It's a very simple page I set up for test purposes only.

HOWEVER, I also have another page (which I'll call 'parent page') which also has a button, which, when pressed, triggers a call to 'window.open()', which takes, as the url argument, "child page" (described above). When I click the button on "parent page", "child page opens as expected, but the button therein no longer works. Instead, I get this error:

[Exception... "'Permission denied to call method XMLHttpRequest.open' when calling method: [nsIDOMEventListener::handleEvent]" nsresult: "0x8057001e (NS_ERROR_XPC_JS_THREW_STRING)" location: "<unknown>" data: no]

All information that I have found online addressing this error message assumes that the script that is called by XMLHttpRequest.open() is on another domain from that which hosts the page that calls XMLHttpRequest.open(). The advice commonly given is based on this assumption, after an explanation of why this is the case from a security point-of-view. However, in my case, EVERYTHING is on the same domain: parent-page, child-page, and the script called (opened) by XMLHttPRequest.open().

I'm using an Apple Macintosh computer. The problem does NOT occur on Safari. It occurs on Firefox. (I don't know yet whether it occurs on Microsoft's browser.) It occurs both on my local production server, as well as when I upload the files to my website. (However, in both cases, everything is confined to their respective domains.)


One strange (and seemingly contrary, based on the online discussions of this error) phenomenon I've noted. Ordinarily, "parent-page" opens "child-page" via window.open() via a RELATIVE path url argument. It opens, like I said, with no problem, but, as described above, throws an error message when its AJAX-triggering button is pressed.

However, when instead, on my local development server (as a test), I provide a full absolute url argument to window.open(), which describes the localhost domain DIFFERENTLY that that url which was used to initially open "parent-page", (for example, I'll use "127.0.0.1" to open parent-page, but I'll hardcode an absolute url path containing "localhost" as an argument to the "child-page"-opening window.open() script in "parent-page), the error clears up!!??

This seems very contrary to all the advice I've seen addressing this error message, i.e., that the domain must be the same. In fact, of course the domain has always been the same in both instances, but the error is not replicated when the domain is described in a DIFFERENT manner, but, strangely, DOES appear when the domain is consistently described exactly the same.

Can anybody shed some light on what could possibly be causing this problem?

CHESTER
benoit.sagols (1) [Avatar] Offline
#2
Re: XMLHttpRequest.open permission denied
Hello, I'm facing wiht the EXACT same problem !! I search everywhere on the web but found nothing ! Just your POST that makes me very happy ! But anybody respond to you...

Anyway did you find a solution to this problem (calling XmlHTTPRequest from a popup...)?

Thanks a lot.
Pascarello (208) [Avatar] Offline
#3
Re: XMLHttpRequest.open permission denied
-edited-

Message was edited by:
Pascarello
Pascarello (208) [Avatar] Offline
#4
Re: XMLHttpRequest.open permission denied
Are you using sub-domains? What does the window.open statement look like? Does one use www and the other doesn't?

Does you request have a leading "/" ?

Eric

Message was edited by:
Pascarello

Message was edited by:
Pascarello
igorgl (2) [Avatar] Offline
#5
Re: XMLHttpRequest.open permission denied
I am faced with the same exact problem on Firefox side.

Was any resolution found? Chapter 7 of your great book does talk about this issue, however when i downloaded the source code for net.js the logic of handling Firefox security was not there.

Please help.

Thanks
davecrane (149) [Avatar] Offline
#6
Re: XMLHttpRequest.open permission denied
Hi Igor,

Could you post a snippet of code showing how the window.open call is being made? Feel free to change the URL if it's confidential, but I need to see how the front of the URL looks i.e. whether it's relative or absolute.

I won't pretend to understand all the inner workings of the security policies on the different browsers. I tend to be fairly conservative in practice, and always use relative URLs, so I don't have to think too much about whether the domain is the same or not. Some of the behaviour described in this thread sounds very odd, I'd be interested to get to the bottom of it!

Cheers,

Dave
igorgl (2) [Avatar] Offline
#7
Re: XMLHttpRequest.open permission denied
Hi Dave,

I was able to resolve the issue and ended up learning a great deal of stuff. I need to restate what my problem was first. My project was to enable "Type-Ahead Suggest" functionality for a bunch of input fields. I started by incorporating JavaScripts described in Chapter 10. Had to make a some changes to satisfy our requirements. All My work was done with IE in mind.
My next step was to make sure all that works in FireFox. Because of the fact that my form has practically no static HTML , almost all elements are build dynamically, first time using FF produced no results (programming for IE does tend to steer you in a wrong direction at times).
My strategy then was to move all my pages and scripts to my local drive and experiment with them there. This is how I ended up with the "security" problem that I posted earlier. Once I finished my changes and moved my stuff back to the server, the problem was gone!

In my "Type-Ahead Suggest" endeavor I had to solve a ton of problems on both sides IE and FF. One of the biggest ones was that "Type-Ahead Suggest" little window in IE would cover most of the input fields but not the Drop Downs. If you are interested in my solution I will be more than happy to share it.

Here is the URL to the test server to the first page of this app - fill in all of the required fields to get to the second page where the "Type-Ahead Suggest" functionality is (look at the "Origin" and "Destination" fields). Since it is our test server and we are not done developing it it might be down once in a while.

http://65.79.187.242:1303/webapp/Term/PriceRequest/Header.jsp

I am also willing to share any little tricks that I had to use to make sure my JavaSripts function in both IE and FF.

Regards,

Igor
francois (1) [Avatar] Offline
#8
Re: XMLHttpRequest.open permission denied
Hi Igor,

I'm trying to get an XMLHttpRequest to a gSOAP server that is used as Web Service using only client side capability. No Server side language support.

I'm still stuck with Access Denied error messages, even after trying all tweek I could find on Firefox to force it to do the request.

Any idea about how I get this working?

Thanks in advance
Francois
gargprabhat (1) [Avatar] Offline
#9
Re: XMLHttpRequest.open permission denied
hi,

I am facing the same issue. I am able to login with below code on local machine.but unable to login on client Machine from server. Facing the below
error.(xmlhttp.open error no -214682821smilie



try
{
var xmlHttp;
if(window.XMLHttpRequest)
{
xmlHttp = new XMLHttpRequest();

}
else if(window.ActiveXObject)
{
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP.3.0");
//xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
//var xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}


var xmlHttpGo = xmlHttp;
var WebServicePath = "http://localhost/PerkWebService/WebServiceLeave/WebServiceLeave.asmx/" ;
var str = WebServicePath + serviceName;
xmlHttpGo.open("POST", str, false);
xmlHttpGo.SetRequestHeader("Content-type","application/x-www-form-urlencoded");
xmlHttpGo.send('xmlreceive=' + objXML.xml);
var xmlString1 = xmlHttpGo.responseXML.text;
return xmlString1;
}
catch(e)
{
return (e.Message + "--> XmlhttpCall"smilie;
}
please send me the resolution.

thanks in advance