简体   繁体   English

JQuery .load()函数不适用于WebKit

[英]JQuery .load() function not working on WebKit

I am trying to use the jQuery.load() function, and it works on Firefox, but not on Safari and Chrome. 我正在尝试使用jQuery.load()函数,该函数可在Firefox上运行,但不能在Safari和Chrome上运行。 The odd part is that it works on mobile Safari. 奇怪的是,它可以在移动Safari上运行。

All of the posts I found on this subject appeared old and outdated. 我发现有关该主题的所有帖子都显得过时和过时。

Does anyone have a solution to fix this problem? 有人有解决此问题的解决方案吗?

Here is sample code from my page: 这是我页面上的示例代码:

<div class="navButton"></div>
<script>
$(".navButton").load("bottomNav.html");
</script>

The error console tells the story here. 错误控制台在这里讲述了故事。

Failed to load resource: the server responded with a status of 404 (Not Found)
      http://yellowtailderby.com/jquery-2.1.0.js

Uncaught ReferenceError: $ is not defined 

So, when you try to execute: 因此,当您尝试执行时:

$(".navButton").load("bottomNav.html");

The $ symbol is not defined because jQuery is not successfully loaded. 未定义$符号,因为未成功加载jQuery。

The issue seems to be that this: 问题似乎是这样的:

http://yellowtailderby.com/jquery-2.1.0.js

does not exist (gets a 404 error) so this script tag: 不存在(出现404错误),因此此脚本标签为:

<script src="jquery-2.1.0.js"></script>

is not working properly. 无法正常工作。 The fix is to either correct the script tag or make sure that particular file is properly located on your server at that path. 解决方法是更正脚本标记或确保特定文件正确位于该路径上的服务器上。


I am getting the exact same error in Firefox, so I suspect that maybe you have that file in your browser cache in Firefox (so it's getting loaded via cache), but it doesn't actually exist on the server. 我在Firefox中遇到了完全相同的错误,因此我怀疑您可能在Firefox的浏览器缓存中包含了该文件(因此通过缓存加载了该文件),但实际上它在服务器上不存在。 The Firefox reports: Firefox报告:

"NetworkError: 404 Not Found - http://yellowtailderby.com/jquery-2.1.0.js"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM