读取本地XML文件时Mozilla中的Jquery AJAX错误 [英] Jquery AJAX error in Mozilla when reading a local XML file

查看:84
本文介绍了读取本地XML文件时Mozilla中的Jquery AJAX错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从XML文件读取一些属性.在IE上工作正常,但在mozilla firefox中却无法正常工作.我的应用程序在用户的本地计算机上本地运行,并且正在从本地驱动器读取XML.

I am reading some properties from an XML file. It is working fine on IE but not in mozilla firefox. My application is running locally on user's local machine and I am reading XML from local drive.

在Firefox中,打开文档的AJAX调用失败.以下是我的代码段.

In Firefox the AJAX call to open the document does not succeed. Below is my code snippet.

如何在Firefox中使用它?

How can I get this to work in Firefox?

 $.ajax({
    type: "GET",
    url: "../branding.xml",
    dataType: "xml",
    success: function(xml) {
        parseXml(xml);
        alert('success');
    },
    error: function(xml) {
        alert('error');
    }
});

我在Firebug中收到以下通知:

I receive the following notice in Firebug:

"[Exception... \"Access to restricted URI denied\" code: \"1012\" 
nsresult: \"0x805303f4 (NS_ERROR_DOM_BAD_URI)\" 
location: \"file:///M:/index/js/jquery-1.7.2.js Line: 8240\"]"

我需要在本地运行此应用程序,并且无法将其放在网络服务器上.有什么建议吗?

I need to run this application locally and cannot put it on a webserver. Any suggestions?

推荐答案

根据

According to Mozilla documentation on same-origin, your XML file must be inside a subdirectory of your page's source directory.

例如,您的网站的结构可能如下:

For example your site may be structured like this:

 my-site/
     index.html
     script.js
     data/
         branding.xml

另一方面,这将有效:

 my-site/
     source/
         index.html
         script.js
     data/
         branding.xml

这篇关于读取本地XML文件时Mozilla中的Jquery AJAX错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆