gpt4 book ai didi

javascript - Jquery load() 只在 Firefox 中工作?

转载 作者:行者123 更新时间:2023-11-28 18:59:03 25 4
gpt4 key购买 nike

我正在尝试进入 jquery/ajax,但我什至不敢相信我无法通过第一个测试。我正在遵循我在 The Jquery API site 找到的示例我跟着它就快到了 T。

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

index.html

list1.html。

<小时/>

索引.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>

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

  • 测试
  • 酒吧

这是浏览器问题吗?为什么 Chrome 和 IE 不显示此加载列表,而 Firefox 却显示?我无法弄清楚是我的代码还是环境在尝试学习时令人恼火。

最佳答案

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

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

关于javascript - Jquery load() 只在 Firefox 中工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32996001/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com