atisman Posted March 19, 2007 Share Posted March 19, 2007 Hi, this might sound a basic question but...Can the XML DOM object load an xml file in any arbitray URL? I have a Javascript that creates a DOM object and I'd like to use load function with a URL that indicates an XML file... For example, using Firefox......xmlDoc=document.implementation.createDocument("","",null);xmlDoc.load("http://www.w3schools.com/xml/xml_note.xml");...I'm running a WEBrick webserver in my local PC and running the script but it doesn't seem to work. But it can load any XML files in my local PC. Any explanation why this happens would be appreciated.Thank you. Link to comment Share on other sites More sharing options...
jesh Posted March 19, 2007 Share Posted March 19, 2007 I haven't used document.implementation.createDocument before, but if it is anything like the XmlHttpRequest (i.e. AJAX), you are prevented from accessing resources across different servers. This is to prevent cross-site scripting.If you need to access a resource that is on a different server from your own, you'll have to use the javascript to access a file on your own server which, in turn, could go out and fetch the file from the other server. PHP or ASP(.NET) or other server-side solutions would allow you to do this. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now