MyEclipse Forums
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
dcolemanca
Post subject: Exception doing HTTP GET on different host in same domain  PostPosted: May 13, 2006 - 11:10 PM



Joined: May 13, 2006
Posts: 1

I am unable to open an HTTP request to a different server in the same domain when debugging a Javascript. It seems to be related to the same-origin restriction of cross-site scripting, but I can execute the same code on Internet explorer and get the expected response from ‘anotherhost.abc.com’

My HTML page is for example hosted at ‘myhost.abc.com’, but I want to do a ‘GET’ on ‘anotherhost.abc.com’.

By doing the following Javascript, I can allow the script to go to other hosts in the same domain:

document.domain = “abc.com”;

I am actually doing stuff with Google Maps so I am using their convenient object GXmlHttp, but underneath the hood they are creating an XMLHttpRequest object.

So here’s the code that works on IE 6 but does not work when debugging from MyEclipse:


var http_request = GXmlHttp.create();

if (!http_request) {
alert("Giving up :( Cannot create an XMLHTTP instance");
return false;
}
http_request.onreadystatechange = function () {
alertContents(http_request);
};
http_request.open("GET", “http://anotherhost.abc.com:8080/file.kml”, true);

The last line gives the following exception in the Javascript Console:

“‘Permission denied to call method XMLHttpRTequest.open’ when calling method: [nsIDOMEventListener::handleEvent]” nsresult: “0x8057001e (NS_ERROR_XPC_JS_THREW_STRING)” location: “<unknown>” data: no]


My config is as follows:

MyEclipse
Version: 4.1.1
Build id: 20060309-4.1.1-GA

Eclipse SDK
Version: 3.1.2
Build id: M20060118-1600
 
 View user's profile Send private message  
Reply with quote Back to top
support-greg
Post subject:   PostPosted: May 16, 2006 - 11:01 AM
Moderator
Moderator


Joined: Mar 31, 2004
Posts: 1612

Looks like you have to tell Mozilla that you want to perform cross-domain scripting. A quick google search returned at least some interesting information.
http://www.captain.at/howto-ajax-permission-denied-xmlhttprequest.php

_________________
Greg
MyEclipse Support
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT - 6 Hours
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2004 The PNphpBB Group
Credits