/    Sign up×
Community /Pin to ProfileBookmark

Cannot load remote XML in Firefox

I have a HTML page on which I am trying to access a remote XML file. However, it gives me an error in Firefox (xmlDoc has no properties)
Here is the code I use;

In the html page;
xmlDoc=loadXMLDoc(“http://mysite.com/abc.xml“);

In the called js;

function loadXMLDoc(dname)
{

if (window.ActiveXObject)
var xmlDoc = new ActiveXObject(“Microsoft.XMLDOM”);
else if (document.implementation && document.implementation.createDocument)
var xmlDoc= document.implementation.createDocument(“”,”doc”,nu ll);

try
{
xmlDoc.async=false;
xmlDoc.load(dname);
return(xmlDoc);
}
catch(e) {alert(“error”)}
return(null);
}

Now here is my question. If I use a local/same domain file (e.g. abc.xml), it works fine both in IE and FF..
But it gives an error if I try to access the remote XML file [url]http://mysite.com/abc.xml[/url]

I know this might have to do something with permission/security, but I can directly access the remote XML file by typing from my browser and also I have set the permssion of the remote XML to lowest 777 (meaning read/write/execute)

If it is not possible to load, can I at least import and then use the XML on my page..
Basically, I need to use a common XML file across various pages/sites.

Please help.
Thank you.

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@A1ien51Jun 15.2008 — The access rights on the server has nothing to do with it.

JavaScript has a same domain policy. So the browser can only access data from the current domain you are in. This is to protect you from sites reading your bank account, email, etc.

Eric
Copy linkTweet thisAlerts:
@askanyquestionsauthorJun 16.2008 — Thanks for your reply....However, just wanted to know if it has to do with javascript, as I am able to access it and get remote XML data in IE...Only Firefox has that problem.

Thank you.
Copy linkTweet thisAlerts:
@askanyquestionsauthorJun 19.2008 — still waiting for a reply
×

Success!

Help @askanyquestions spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.28,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...