NS_ERROR_DOM_BAD_URI:访问受限制的URI被拒绝xhr.send(有效载荷);

时间:2015-07-29 14:03:22

标签: javascript html i18next

我正在实施i18next javascript用于国际化目的。我加载HTML页面时出现此错误。

NS_ERROR_DOM_BAD_URI: Access to restricted URI denied
xhr.send(payload);  

这是我的html代码:

<!DOCTYPE html>
<html>

<head>
    <title>Internationalization</title>
    <meta charset="UTF-8">
    <script src="js/i18next-1.10.1.js"></script>
</head>

<body>
    <span data-i18n="[html]page-home.headline.title"></span>
    <script type="text/javascript">
    var options = {
        lng: "en",
        resGetPath: './../locales/__lng__/__ns__.json'
    };

    i18n.init(options, function(t) {
        $(".nav").i18n();
    });
    i18n.init(options, function(t) {
        var title = t("page-home.headline.title");
    });
    </script>
</body>

</html>  

我的translation.json是:

{
 "app": {
   "name": "i18next"
 },
 "nav": {
   "home": "home",
   "services": "leistungen",
   "contact": "kontakt",
   "quotation" : "angebot anfordern",
   "base-title": " | davidhamann media | FileMaker- und Web-Entwicklung aus Hamburg"
 },

 "services":  {
       "link-web" : {
           "title" : "Web-Entwicklung & Web-Design",
           "text" : "Wir entwickeln moderne, robuste Web-Applikationen für Unternehmen und Institutionen jeder Größe.
Sprechen Sie uns an."
       },
       "link-filemaker" : {
           "title"  : "FileMaker-Entwicklung",
           "text" : "Als zertifizierter FileMaker-Entwickler und Mitglied der FileMaker Business Alliance bieten wir Ihnen individuelle Datenbanklösungen höchster Qualität."
       }
 },
   "page-home": {
       "headline" : [
           {
               "title" : "GUTEN TAG.",
               "text" : "Wir entwickeln Software, die individuell auf Sie zugeschnitten ist."
           },
       ]}
}  

为什么我收到此错误?
Update:
我在chrome和chrome中尝试过这些错误:

XMLHttpRequest cannot load file:///C:/Users/Ajay%20Kulkarni-enEXL/Desktop/locales/en/translation.json?_=1438178780772. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource.(anonymous function) @ i18next-1.10.1.js:683getXhr @ i18next-1.10.1.js:464ajax @ i18next-1.10.1.js:641http.get @ i18next-1.10.1.js:702_ajax @ i18next-1.10.1.js:743sync._fetchOne @ i18next-1.10.1.js:236(anonymous function) @ i18next-1.10.1.js:199_each @ i18next-1.10.1.js:429(anonymous function) @ i18next-1.10.1.js:179_each @ i18next-1.10.1.js:429sync._fetch @ i18next-1.10.1.js:178sync.load @ i18next-1.10.1.js:128init @ i18next-1.10.1.js:988(anonymous function) @ index.html:18
i18next-1.10.1.js:683   
Uncaught NetworkError: Failed to execute 'send' on 'XMLHttpRequest': Failed to load 'file:///C:/Users/Ajay%20Kulkarni-enEXL/Desktop/locales/en/translation.json?_=1438178780772'.  

1 个答案:

答案 0 :(得分:0)

  

XMLHttpRequest无法加载file:///

文件系统URI受到限制。使用Web服务器托管您的站点并通过HTTP加载它。