Javascript 未找到 JS 文件 (404)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/37261879/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
JS files not found (404)
提问by Falpangaea
I'm running the application locally and it works fine. When I uploaded it to my hosting account I started getting 404 errors on JS
我在本地运行应用程序,它工作正常。当我将它上传到我的托管帐户时,我开始在 JS 上收到 404 错误
It's happening in both Chrome and Firefox.
它发生在 Chrome 和 Firefox 中。
The files are located in the designated location and the code is at the bottom of the page so they shouldn't be getting accessed before they're loaded.
文件位于指定位置,代码位于页面底部,因此在加载之前不应访问它们。
<script src="libs/bootstrap-switch-master/docs/js/jquery.min.js"></script>
<script src="libs/bootstrap-toggle-master/js/bootstrap-toggle.min.js"></script>
<script src="libs/angular/angular.js"></script>
<script src="libs/angular/angular.min.js"></script>
<script src="libs/angular-auto-validate/dist/jcs-auto-validate.min.js" ></script>
<script src="libs/ladda/dist/spin.min.js" ></script>
<script src="libs/ladda/dist/ladda.min.js" ></script>
<script src="libs/angular-ladda/dist/angular-ladda.min.js"></script>
<script src="libs/clipboard.js-master/dist/clipboard.min.js"></script>
<script src="libs/jquery-color-master/jquery.color.js"></script>
<script src="main.js" ></script>
</body >
</html >
回答by Eitan K
In Chrome Developer Tools (F12 in Google Chrome), if you go to the sources tab you can see the content (css and js) that is on the page. It appears that some of your files are missing and some of the directories are incorrect.
在 Chrome 开发者工具(Google Chrome 中的 F12)中,如果您转到源选项卡,您可以看到页面上的内容(css 和 js)。您的某些文件似乎丢失了,某些目录不正确。
It looks like with some of the content you assumed that support-wizard was the root directory when it isn't.
对于某些内容,您认为 support-wizard 是根目录,但实际上并非如此。
For example, some of your sources should be:
例如,您的一些来源应该是:
/support-wizard/libs/ladda/dist/spin.min.js
/support-wizard/libs/ladda/dist/ladda.min.js
/support-wizard/libs/bootstrap-toggle-master/css/bootstrap-toggle.min.css
If you try going to each page it should load (ie: ztsales.com/support-wizard/libs/ladda/dist/ladda.min.js)
如果您尝试访问它应该加载的每个页面(即:ztsales.com/support-wizard/libs/ladda/dist/ladda.min.js)
回答by Falpangaea
Solved.
解决了。
It was a permissions issue. The PATHs were right but the problematic directories and files didn't have execute permissions.
这是一个权限问题。PATH 是正确的,但有问题的目录和文件没有执行权限。
EDIT(zpert): Make sure directory permissions are 755, which means:
编辑(zpert):确保目录权限为 755,这意味着:
- Owner: Read, Write, Execute
- Group: Read, Execute
- Public: Read, Execute
- 所有者:读取、写入、执行
- 组:读取、执行
- 公开:读取、执行