.load()和相对路径

Bra*_*roy 8 jquery path jquery-load

.load()给我带来麻烦.我正在处理一个节段加载器项目,我似乎无法获取我需要的文件.

我想要实现的目标: #sectionContainer在文档加载时是空的,但在文档就绪时它被"填充"了Pages1.html.这是通过JavaScript文件完成的sections.js.JS文件和index.html不在同一个文件夹中.这是网站结构(我在我的网站上运行了很多项目)

  • 主文件夹
    • 项目1
    • 项目2(sectionLoaderTest /)
      • 的index.html
      • Pages1.html
      • Pages2.html
      • CSS /
      • JS /
        • sections.js
    • 项目3
    • ...

我用来加载Pages1.html的代码:

$(document).ready(function () {
    $("#sectionContainer").load("../Pages1.html", function (response, status, xhr) {
        if (status == "error") {
            var msg = "An error occurred. Status code: ";
            $("#error").html(msg + xhr.status + ". Status text: " + xhr.statusText);
        }
    });
});
Run Code Online (Sandbox Code Playgroud)

我已经尝试了我所知道的所有可能的方法(/,.,.,..,...),似乎没有任何工作.这是测试用例.

有谁知道我做错了什么?

Mar*_*cck 7

./Pages1.html应该管用.在地址栏中测试了所有帐户.