Jquery load() 只能在 Firefox 中工作? [英] Jquery load() only working in firefox?

查看:32
本文介绍了Jquery load() 只能在 Firefox 中工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试进入 jquery/ajax,我什至不敢相信我无法通过第一次测试.我正在遵循我在 The Jquery API 站点 上找到的示例,然后我将其跟踪到了 T.

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

index.html

list1.html.

<小时>

Index.html:

<头><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script><身体><div id="舞台">

<脚本>$( "#stage" ).load( "list1.html" );

list1.html

<li>测试</li><li>Foo</li><li>条形</li>

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

  • 测试
  • 酒吧

这是浏览器的问题吗?为什么 Chrome 和 IE 不显示此加载列表,但 Firefox 会显示?我想不通是我的代码还是环境让我在尝试学习时感到恼火.

解决方案

尝试使用 --allow-file-access-from-files 标志集启动 chrome/Chromium

如何使 Google Chrome 标记--allow-file-access-from-files"永久化?

I am trying to get into jquery/ajax and I can't even believe I can't get past this first test. I'm following an example I found at The Jquery API site and I followed it just about to a T.

I created a local folder on the desktop, and added 2 files.

index.html

and

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>

I was trying for like 15 minutes to run index.html in chrome and nothing displayed (like the jquery wasn't loading correctly). Out of pure curiosity I opened it with firefox and it displayed as expected.. something like this

  • Test
  • Foo
  • Bar

So is this a browser issue? Why does Chrome and IE not show this loaded list, but firefox does? I can't figure out if it's my code or the environment which is infuriating when trying to learn.

解决方案

Try launching chrome / chromium with --allow-file-access-from-files flag set

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

这篇关于Jquery load() 只能在 Firefox 中工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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