简体   繁体   English

找不到JS档案(404)

[英]JS files not found (404)

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都在发生这种情况。

Chrome Inspect Element Errors Chrome检查元素错误

The directory structure 目录结构

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 > 

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. 在Chrome开发者工具(Google Chrome中为F12)中,如果转到“源”选项卡,则可以看到页面上的内容(css和js)。 It appears that some of your files are missing and some of the directories are incorrect. 看来您的某些文件丢失,某些目录不正确。

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)

Solved. 解决了。

It was a permissions issue. 这是一个权限问题。 The PATHs were right but the problematic directories and files didn't have execute permissions. 路径正确,但是有问题的目录和文件没有执行权限。

EDIT(zpert): Make sure directory permissions are 755, which means: 编辑(z​​pert):确保目录权限为755,这意味着:

  • Owner: Read, Write, Execute 所有者:读取,写入,执行
  • Group: Read, Execute 组:读取,执行
  • Public: Read, Execute 公开:读取,执行

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

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