Jquery load() 只能在 firefox 中工作?

Jquery load() only working in firefox?

我正在努力进入 jquery/ajax,我什至不敢相信我无法通过这第一次测试。我正在按照我在 The Jquery API site 找到的示例进行操作,然后我就按照它进行了 T.

我在桌面上创建了一个本地文件夹,并添加了 2 个文件。

index.html

list1.html.


Index.html:

<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
</head>

<body>

<div id="stage">
</div>

<script>
$( "#stage" ).load( "list1.html" );
</script>

</body>

</html>

list1.html

<div id="list">
<li>Test</li>
<li>Foo</li>
<li>Bar</li>
</div>

我在 chrome 中尝试 运行 index.html 大约 15 分钟,但没有显示任何内容(例如 jquery 未正确加载)。出于纯粹的好奇心,我用 firefox 打开它,它按预期显示.. 像这样

这是浏览器问题吗?为什么 Chrome 和 IE 不显示此加载列表,但 firefox 显示?我不知道是我的代码还是环境在尝试学习时令人恼火。

尝试

<script>
    $(function(){
       $("#stage").load("list1.html");
    });
</script>

如果仍然无法正常工作,请检查浏览器开发人员工具中的网络部分,看看是否存在任何 HTTP 或安全错误。

尝试启动 chrome / 设置 --allow-file-access-from-files 标志的 chromium

How do I make the Google Chrome flag "--allow-file-access-from-files" permanent?