hi_i'm_greg
hi_i'm_greg

Reputation: 3

Loading XML File with Ajax. Successful in IE and Safari. Strange Firefox behaviour

been following posts on this site for a while and find them very helpful. This is my first post, so bear with me.

I'm loading an XML file using ajax (once loaded i'm processing the information with jquery). It contains information i'm using to build thumbnails, picture galleries and slideshows. However the xml file doesn't seem to load in firefox. IE and Safari have no problem doing so, so i'm cind of stuck. I havn't tested chrome or opera yet, since they don't allow local xml.

The thing is, the problem has only occured, since i changed the location of the xml file. It used to be in the same folder as the javascript file, in which i'm placing the ajax command. So the following worked fine in IE Safari and Firefox:

$.ajax({
    type: 'GET',
    url: 'projects.xml',
    dataType: 'xml',
    success: parseXML
});

Now that the xml is in a seperate folder a level up, firefox only loads it when i navigate to the html file via link (navigating to the html file via address bar or refresh results in firefox not loading the xml). So I'm suspecting Firefox has some trouble with the "../" expression. Is this true? Is this merely a problem from working offline? Here's the code i'm now using:

$.ajax({
    type: 'GET',
    url: '../xml/projects.xml',
    dataType: 'xml',
    success: parseXML
}); 

Any help will be appreciated.

Upvotes: 0

Views: 691

Answers (1)

Boris Zbarsky
Boris Zbarsky

Reputation: 35064

Firefox treats files in directories higher up the tree as not-same-origin when working with file:// URIs. This is to prevent local HTML files reading arbitrary data from your hard drive.

So yes, this is due to your use of .. and only a problem when you use file:// URIs.

Upvotes: 1

Related Questions