• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Permission Denied Error

 
Ranch Hand
Posts: 261
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

While I am aware that both Firefox and IE have a "same domain policy" as a security measure, I write to seek some other options to implement my requirements.

The situation I have is:
We have a web application wherein a Javascript method makes an AJAX call to the server to receive XML data and then converts it into HTML content and then populates this content within DIV elements having a particular ID. (Something similar to say Google Maps.)

However the problem arises when a user of my server's functionality makes a call to the Javascript method from an HTML page operating in some other domain. The user includes the script from my domain in his/her HTML page. And thereof, when needed, the ID of the DIV element to be populated is passed to my method from that HTML page. But whenever, my method makes the AJAX call, I get the "Permission Denied" error. I have reasearched the web and realized this is a security feature in browsers.

So it will be really helpful for me if anyone can guide me an alternative way to implement this kind of a functionality.

Thanks a lot :-]
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Take a look at this example I wrote awhile back.

http://www.pascarello.com/examples/JsonYahooExample.html

The example sses JSON to talk to an outside server. You can see the code by viewing the source of the page or looking at it in Firebug.

Eric
 
Anirvan Majumdar
Ranch Hand
Posts: 261
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Eric,

The reason I want to avoid using JSON is the overheads involved in transforming the XML data into JSON. And besides, I have never worked with JSON so there would be some overheads involving time too. Is there some other simpler way in which I can continue using the AJAX call from the remote Javascript?

----------------------------
Web Server 1 = www.abc.com
----------------------------
<script src="http://www.xyz.com/js/data.js"/>

----------------------------
Web Server 2 = www.xyz.com (data.js)
----------------------------
// Makes AJAX call to application and transforms the XML data into
// HTML and then populates DIVs present in the HTML document that
// invoked it.


As of now, I keep getting the "Permission Denied" error.

 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
JSON is rather easy, it is just like XML, only in a simple form without < and > tags. Learn JSON and you learn a new and hot skill. It will take you 5 minutes to undertand it.

Goto http://json.org/ and gives you the basic information. Look at the bottom and there is info on differnet languages.

You are not going to be able to use Ajax accross domains. You already know that, so this is your only real option unless you want the people running this code to have to run a local proxy. I doubt you would want to do that.

Eric
 
Sheriff
Posts: 67753
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actually you can run a proxy on your local server to access remote services; I went into great detail on how to do this in the Web Services chapter of Ajax in Practice.

Basically, you write a servlet (or other server-side processing unit) to access the remote service on your behalf, collect the response and relay it to your page. Because the servlet is on the server, it is not subject to the browser's cross-domain restrictions.
 
Anirvan Majumdar
Ranch Hand
Posts: 261
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@ Eric: JSON does look like a neat alternative, albeit the reluctance to change from the all too familiar XML :-/ Have started learning about JSON nonetheles.

@ Bear: Yups, have already put the proxy into place. But as things have a way to get entangled, our web app is Java based while one of the users of our services has the web app running behind an IIS server. Durned I haven't got any about IIS (totally into Tomcat and Apache) and those folks aren't particularly bright with proxies. Any pointers as to where I can get some proxy related help w.r.t IIS?

Also, any ideas as to how the folks @ Google implemented their Maps application? Is it also JSON based 'coz there's no question of proxies and it is all about cross browser scripting.

Thanks a lot to all.
[ November 16, 2007: Message edited by: Anirvan Majumdar ]
 
Whip out those weird instruments of science and probe away! I think it's a tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic