Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/78.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
无法使用带有load函数的jQuery脚本加载图像_Jquery_Html_Loading - Fatal编程技术网

无法使用带有load函数的jQuery脚本加载图像

无法使用带有load函数的jQuery脚本加载图像,jquery,html,loading,Jquery,Html,Loading,我正在使用jQuery脚本加载nav.html和footer.html。我的问题是,当我在Wamp中测试我的网站时,一切正常。当我把它加载到我真正的web服务器时,它不会加载我的徽标。我不知道为什么,也找不到任何东西 这是我的nav.html <meta content="text/html;charset=utf-8" http-equiv="Content-Type"> <meta content="utf-8" http-equiv="encoding"> <

我正在使用jQuery脚本加载nav.html和footer.html。我的问题是,当我在Wamp中测试我的网站时,一切正常。当我把它加载到我真正的web服务器时,它不会加载我的徽标。我不知道为什么,也找不到任何东西

这是我的nav.html

<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<meta content="utf-8" http-equiv="encoding">
<html>
 <head>
  <title></title>
  <link rel="stylesheet" type="text/css" href="style.css" async>
 </head>
 <body border="1" style="hight:60, border-bottom: 5px solid cyan; vertical-align: middle;">
  <br>
  <img src="attf.png" width="256px">
  <a id="button" href="index.html">Home</a>
  <a id="button" href="gameserv.html">Game Servers</a>
  <a id="button" href="comsserv.html">Communication Servers</a>
  <br>
  <br>
 </body>
</html>




下面是我如何将nav.html加载到我的网页中

<head>
 <title></title>
 <link rel="stylesheet" type="text/css" href="style.css" async>
 <script src="//code.jquery.com/jquery-1.10.2.js"></script>
 <script>
  $(function(){
   $("#nav").load("nav.html");
   $("#footer").load("footer.html");
  });
 </script>
</head>
<body border="1">
 <div id="nav"></div>
 <div id="footer"></div>
</body>

$(函数(){
$(“#nav”).load(“nav.html”);
$(“#footer”).load(“footer.html”);
});

如果有帮助,您可以在找到我的网站。

您正在
中加载完整的HTML页面

html不应包括
标记。这在
标记中是不正确的

将其更改为以下内容:

<link rel="stylesheet" type="text/css" href="style.css" async>
<div border="1" style="hight:60, border-bottom: 5px solid cyan; vertical-align: middle;">
 <br>
 <img src="attf.png" width="256px">
 <a id="button" href="index.html">Home</a>
 <a id="button" href="gameserv.html">Game Servers</a>
 <a id="button" href="comsserv.html">Communication Servers</a>
 <br>
 <br>
</div>





对于样式表,您可能希望查看一些不同的内容,以将
标记放置在
中,但它可能是内联的。另一种方法是在CSS中使用
标记,但这使得它100%内联,这可能不是您想要的。

也感谢Alexis提供了关于更好的构建习惯的信息。此外,geedubbs和rupps还指出,这可能是一条糟糕的道路或其他类似的问题

我发现我的web服务器区分大小写


谢谢大家,这让我忙了大约一个小时。

你上传了吗?现在是404?一般来说,这些错误都是通过打开开发者工具解决的。在Chrome菜单中,选择更多工具>开发者工具。在Safari和Firefox中是类似的。这些工具有一个控制台,可以打印出在页面中发现的错误。可能是因为路径不正确或上传被遗忘,所以你得到了404(未找到文件)。对于Firefox,我使用FireBug,只需执行F12操作即可打开它。是的,它就在那里,很奇怪,因为它因为某种原因无法加载。好的,我会做一些更正,让你知道它是如何工作的。还感谢您编辑我的错误。:)我做了更正,只留下了身体标签内的所有东西,并在我的Wamp环境中进行了测试,所有东西看起来都一样。我已将新文件移到web服务器,但仍然存在相同的问题:/为了确保缓存没有问题,您可能需要查看源代码(右键单击,在Firefox中查看页面源代码)是的,现在我可以避免在nav中使用任何CSS样式。处的源代码显示img标记,它只是不想加载。