简体   繁体   English

403在本地主机上开发时禁止Jquery.min.js

[英]403 Forbidden for Jquery.min.js when developing on localhost

I've looked all over google and the site and none of the solutions I've tried have worked... maybe my problem requires something a little more specific. 我到处都在Google和网站上浏览,而我尝试过的解决方案都没有奏效……也许我的问题需要更具体的说明。

When I have this site hosted on a test site, it works fine, but I'm getting this error when I use "Inspect Element" on Chrome: Failed to load resource: the server responded with a status of 403 (Forbidden). 当我将此站点托管在测试站点上时,它可以正常工作,但是当我在Chrome上使用“检查元素”时出现此错误:无法加载资源:服务器的响应状态为403(禁止)。 I can tell the jquery file isn't being accessed properly by my site because the jquery that works perfectly on my Go Daddy test site (a cool little tool called Tablesorter) isn't working anymore. 我可以知道我的网站无法正确访问jquery文件,因为在我的Go Daddy测试网站(一种名为Tablesorter的酷小工具)上正常工作的jquery不再起作用。

The jquery.min.js file is in a directory called js. jquery.min.js文件位于名为js的目录中。 Here's the entirety of the head in my html file. 这是我的html文件中的整个头部。

<head>
<title>Corporate Dude, Data Management</title>
<script type="text/javascript" src="js/jquery.min.js"></script> 
<script type="text/javascript" src="js/jquery.tablesorter.js"></script>
<link rel="stylesheet" type="text/css" href="style.css?v=1.9"/>
<script type="text/javascript">
    $(document).ready(function() 
        { 
            $("#data_table").tablesorter(); 
        } 
    );
</script>
</head>

The weird thing is that when I move the style.css file into the js directory and change the path to js/style.css, the css works just fine. 奇怪的是,当我将style.css文件移到js目录并将路径更改为js / style.css时,css正常工作。 Does this mean it's not a permissions issue or is it just a peculiarity of the way href works in the link tag? 这是否意味着这不是权限问题,还是href链接标记工作方式的特殊性?

I've tried going to the terminal and typing cd /Users/myusername/mylocalhostfile/"Corporate Guy"/js then typing chmod 0755 to give permission to access the directory, but that didn't work either. 我试着去终端并输入cd / Users / myusername / mylocalhostfile /“ Corporate Guy” / js,然后输入chmod 0755来授予访问目录的权限,但这也不起作用。 Is this the proper way to assign permissions through the terminal? 这是通过终端分配权限的正确方法吗?

Thanks for any help you can give me. 感谢你给与我的帮助。

I had the same problem: accessing jquery locally would not work but accessing it remotely from " http://code.jquery.com/jquery-1.7.2.min.js " would work. 我遇到了同样的问题:无法在本地访问jquery,但可以从“ http://code.jquery.com/jquery-1.7.2.min.js ”远程访问jquery。 The problem is that when I downloaded jquery it was stored without reading access to everyone (as json_parse... has below): 问题是,当我下载jquery时,它的存储没有读取所有人的权限(如json_parse ...具有以下内容):

-rw-r----- 1 jorge jorge  94840 ago  6 04:07 jquery-1.7.2.min.js
-rw-r--r-- 1 jorge jorge   9866 jun 25 06:18 json_parse_20091204.js

I changed it thus: chmod +r jquery-1.7.2.min.js 我这样更改了它: chmod +r jquery-1.7.2.min.js

-rw-r--r-- 1 jorge jorge  94840 ago  6 04:07 jquery-1.7.2.min.js

Please check file permissions; 请检查文件权限; it should have read access. 它应该具有读取权限。 I was facing the same issue with AngularJS lib; 我在AngularJS lib中也遇到了同样的问题; When I was trying to access it from locally running apache2 server, I was getting: Failed to load resource: the server responded with a status of 403 (Forbidden) 当我尝试从本地运行的apache2服务器访问它时,我得到:无法加载资源:服务器以403(禁止)状态响应

The file had not read permissions: 该文件没有读取权限:

-rw-r----- 1 root root 147059 Aug 29 20:20 angular.min.js -rw-r ----- 1个根147059年8月29日20:20 angular.min.js

Added read-permissions by running: 通过运行以下命令添加了读取权限:

sudo chmod +r angular.min.js

And now it's working fine. 现在一切正常。

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

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