View Full Version : Permission denied to call method XMLDocument.load

sir pannels
05-09-2007, 04:21 PM
Hi all,

I'm trying to load an XML file using DOM via JS however having some problems. Works in all browsers other than firefox.

The problem is, if I try to access a XML file on remote machine firefox says "Error: uncaught exception: Permission denied to call method XMLDocument.load"

Works on IE and Opera as I said. The code Im using ..


Any thoughts?
Thanks very much,
Sir P :D

05-09-2007, 04:24 PM
It is my understanding of the security model that you cannot give full absolute URLs to load(). You can only load from your own same-origin server so have to use a relative path like


I'm surprised it works in the other browsers.


sir pannels
05-09-2007, 04:28 PM
Hi David,

Thanks for you reply.

If that is the case, how do RSS feeds and so forth work ? :s

Sir P

05-09-2007, 05:37 PM
I've never written one myself but my understanding is they can be done in a number of ways. One way is to use the xml.load() function but proxy the rss feed on your own server so it doesn't violate the same-origin security policy (http://en.wikipedia.org/wiki/Same_origin_policy).

Another way is to "trick" the browser into getting data from another site by adding a <script> tag dynamically to the your html page. The script is loaded and the javascript is parsed. If the javascript has something like

var textResponse = "<books><book><title>...";

Then when the parsing is finished that xml text will be available for parsing into an xml dom object. Usually this system uses a callback function to say when the <script> tag has been loaded and parsed. I suspect this is how Google does it (although I haven't looked at the source to find out).