|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
JavaScript XML Access Denied error
Hello all.. I have been racking my brain and can't for the life of me figure out why I am getting this error. I have some javascript code that opens an XML document on another server and everytime I go to load the xml document (i.e xmlDoc.load("http://www.someserver.com/mydoc.xml"); I get a javascript error that says Access denied. If I load that same XML document on the same server it works GREAT... whats going on? HELP... here is my html code....
<html> <head> <script type="text/javascript"> function RunXML() { var xmlDoc = new ActiveXObject("Msxml2.DOMDocument"); xmlDoc.async = false; xmlDoc.load("http://www.someserver.com/mydoc.xml"); alert(xmlDoc.xml); } </script> </head> <body bgcolor="blue" onLoad="RunXML();"> </body> </html> I greatly appreciate any help anyone can offer.. thanks.. |
|
#2
|
|||
|
|||
|
I think it is due to IE Security restrictions. I remember reading about it, I think the solution is to lower them...
http://www.w3schools.com/xml/tryit....=httprequest_js Might be another way to try it |
|
#3
|
|||
|
|||
|
|
|
#4
|
|||
|
|||
|
Hi,
I have a very similar problem. I am trying to access an XML file on a remote server. The file that I would like to load is... http://feeds.feedburner.com/tapestrydilbert.xml I can load it into my browser (FF or IE) file and I have a Yahoo Widget that can also access this file without problem. However my code always get an Access denied message when trying to load it. Unfortunately, I'm not very experienced with JS (yet). I have a reasonable working knowledge of XML and many years experience of VB / HTML and some other development languages. My code is this... if (document.implementation && document.implementation.createDocument) { // FF var xmlDoc = document.implementation.createDocument("", "", null); } else if (window.ActiveXObject) { var xmlDoc = new ActiveXObject("Microsoft.XMLDOM"); } else { alert('Unable to create an XML document.'); return sUrl; } xmlDoc.async = false; xmlDoc.validateOnParse = false; try { xmlDoc.load('http://feeds.feedburner.com/tapestrydilbert.xml'); } catch(er) { alert("Unable to open XML: " + er); return sUrl; } The .load method always raises the error. I have tried FF and IE browsers and a range of other XML files at other locations, but without clear results, so I can't say for sure what sort of problem is the cause. ![]() All help welcomed, ![]() Regards, Martin |
|
#5
|
||||
|
||||
|
You can't load via AJAX files that are in a different domain that the one that is serving the page that executes the AJAX call. You should use server side programming to do that: call via AJAX a PHP (ASP, JSP, whatever...) file that connects to the remote server, retrieves the file and then sends it to your JS script.
__________________
-- No, no... he's not dead, he's, he's restin'! Remarkable bird, the Norwegian Blue, isn'it, ay? Beautiful plumage!! |
|
#6
|
|||
|
|||
|
Thanks for that answer. I have no idea what AJAX is, but I guess some reading should solve that. Unfortunately, I have to run this client side so can't use your suggestion. If you have time maybe you could explain why the browser can open it but not the JS. (Educational purposes...)
Is it possible to grab the file as text and then read the XML in manually? I assume that this limitation is brought in for security reasons and therefore this sort of thing is blocked, but maybe it's worth a try. Thanks, Martin |
![]() |
| Viewing: Dev Shed Forums > Web Design > JavaScript Development > JavaScript XML Access Denied error |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|