Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to disable Firefox3 exception throw when ajax try to open url from outside domain

137 views
Skip to first unread message

Oceanedge

unread,
Aug 12, 2008, 9:27:19 PM8/12/08
to
I'm trying to develop a local web application to access Myspace REST
APIs by using java script & ajax. Here is my code:
request = new XMLHttpRequest();
request.onreadystatechange = handleResponse;
request.open("GET", fUrl, true);
request.setRequestHeader("Cache-Control", "no-cache");
The fUrl value is "http://api.myspace.com/...". The html file in
located in local file system. So the domain of the url is outside.
When request.open() is called, an exception is thrown:
Exception... "Access to restricted URI denied" code: "1012" nsresult:
"0x805303f4 (NS_ERROR_DOM_BAD_URI)" location: "file:///D:/mypro/WebKit/
MySpace1/src/MySpace1/scripts/oauthTest.js Line: 80"

Any from the AJAX:Getting Started article in mozilla developer center,
I know it is a security mechanism of firefox3. I wonder if I can
disable it, cause I like the Firebug addon very much, I hope I can
debug my application within Firefox.
Please help. Thanks!

Kem Apak

unread,
Aug 15, 2008, 5:53:10 AM8/15/08
to dev-...@lists.mozilla.org
Hi,

If I understand correctly you are trying to use AJAX with different
domains. This is not possible.

if you want to use AJAX from domain A for example, The page has to be
served by domain A. Otherwise you are out of luck there are security
restrictions.

You might investigate script injection, this is not a good solution
(Actually it has quite a few side effects) but it might help.

Cheers,

Kem

> _______________________________________________
> dev-ajax mailing list
> dev-...@lists.mozilla.org
> https://lists.mozilla.org/listinfo/dev-ajax

Oceanedge

unread,
Aug 25, 2008, 5:11:48 AM8/25/08
to
Thanks, I know this logic has security issues. But I found both IE &
Safari allows it. And what I am developing is a WebUI application(Like
Google Gadget, Web Widget etc) running on local system. Its JavaScript
code is executed by the local web browser engine(WebKit). And it's
accessing information from remote http server by ajax. So the domain
is actually different.
Now I can only test it in Safari & IE, but they both lack of powerful
JavaScript debug addon. So I want to debug it in Firefox.

> > dev-a...@lists.mozilla.org
> >https://lists.mozilla.org/listinfo/dev-ajax

thart...@gmail.com

unread,
Sep 3, 2008, 7:00:44 PM9/3/08
to

I am having the same issue. Have you resolved this ?

Luke Yan

unread,
Sep 30, 2008, 10:34:54 PM9/30/08
to
hi

a correct solution for cross-domain issue is to use a Server-Proxy to forward
the request.

For details, you can wirte a script (JSP, PHP or anything else) on your site and
the JS will call that scriptm which will call the API on the other sites.

if there is still anything not clear, please let me know

thanks
luke

ÔÚ Wed, 3 Sep 2008 16:00:44 -0700 (PDT) ʱ, thart...@gmail.com дÁË:
--

guillaume....@gmail.com

unread,
Oct 7, 2008, 8:52:14 AM10/7/08
to
Do you have a sample script to do it ?


On Oct 1, 4:34 am, Luke Yan <gumpag...@163.com> wrote:
> hi
>
> a correct solution for cross-domain issue is to use a Server-Proxy to forward
> the request.
>
> For details, you can wirte a script (JSP, PHP or anything else) on your site and
> the JS will call that scriptm which will call the API on the other sites.
>
> if there is still anything not clear, please let me know
>
> thanks
> luke
>

> ÔÚ Wed, 3 Sep 2008 16:00:44 -0700 (PDT) ʱ, thartist...@gmail.com дÁË:

kuldee...@gmail.com

unread,
Nov 14, 2008, 12:51:51 AM11/14/08
to gum...@163.com
> > >I am having the same issue.  Have you resolved this ?- Hide quoted text -
>
> - Show quoted text -

Hi gumpag,

I m facing same error.Please provide a sample code (scripts/jsp).
Thanks in Adavance !!!

Regards
Kuldeep

0 new messages