jQuery 未加载
我正在使用 php。
当我在谷歌服务器上使用 jquery-1.3.2-min.js 时,它会加载并且一切运行正常。
但是当我尝试使用我下载到我的服务器上的那个时,Firebug 给了我这样的信息:
1<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
2<html><head>
3<title>403 Forbidden</title>
4</head><body>
5<h1>Forbidden</h1>
6<p>You don't have permission to access /path/to/scripts/jquery-1.3.2.min.js
7on this server.</p>
8<hr>
9<address>Apache/2.2.12 (Ubuntu) Server at localhost Port 80</address>
10</body></html>
我该如何修复它?我是否需要更改 Apache 中的某些设置?
另一件事是还有另一个 js 文件(使用 jquery 的文件)加载得很好。它与 jquery-1.3.2.min.js 位于同一文件夹中(即在脚本文件夹中)。
I'm using php.
When I use the jquery-1.3.2-min.js on google's server, it loads and everything runs fine.
But when I try to use the one I downloaded to my server, Firebug gives me this:
1<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
2<html><head>
3<title>403 Forbidden</title>
4</head><body>
5<h1>Forbidden</h1>
6<p>You don't have permission to access /path/to/scripts/jquery-1.3.2.min.js
7on this server.</p>
8<hr>
9<address>Apache/2.2.12 (Ubuntu) Server at localhost Port 80</address>
10</body></html>
How can I fix it? Do I have to change some settings in Apache.
The other thing is there is another js file (the one that uses the jquery) that loads just fine. It is in the same folder as the jquery-1.3.2.min.js (i.e. in the scripts folder).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
听起来像是文件本身的权限问题。尝试
Sounds like a permissions issue on the file itself. Try
我刚刚发生了一件非常相似的事情。对我来说解决这个问题的方法是获取不起作用的文件并将文件的内容复制到新文件中。 EG 在我的实例中,获取 JQuery 文件,打开它,复制到新的 JS 文件中,保存,移动旧文件,将新文件放在同名的同一位置......然后一切正常。
I just had a very similar thing happen. What fixed it for me was taking the file that wasn't working and copying the content of the file into a new file. E.G. In my instance, take the JQuery file, open it, copy into a new JS file, save, move old file, put new file in same place with same name... then it all worked fine.
您需要检查用户对这些目录/文件的权限。如果您无法自行解决此问题,请考虑与您的房东联系。
You need to check your users permissions with regards to those directories/files. Consider contacting your host about this issue if you are unable to resolve it yourself.
如果 apache 可以读取一个文件但不能读取另一个文件。使用 chmod 或 chown 检查文件的权限,看看是否有区别。将文件设置为与其他可以正常加载的 javascript 文件相同的权限。
If apache can read one file but not the other. Check the permissions on the file use chmod or chown and see if that makes a difference. Set the file to the same permissions of the other javascript file that loads fine.
除了检查权限之外,还可以在路径前加上此前缀,然后查看:
Apart from checking permissions, prefix the path with this and then see:
如果在 apache 中启用了 suphp 模块,则必须调整 jquery 文件的权限和所有者。
查看文件的权限,
如果权限不同,您可以使用eg调整jquery-1.3.2.min.js文件的权限
,如果所有者不同,您可以使用调整它
If the suphp module is enabled in apache you have to adjust the permissions and the owner of the jquery file.
Take a look at the permissions of the files with
if the permissions are different you can adjust the permissions of the jquery-1.3.2.min.js file with e.g.
and if the owner is different you can adjust it with
此解决方案不会解决您的权限问题,但最好从 Google 加载 jQuery 库。
Google 托管了几个流行的 JS 库。
主要优点是许多人已经从 Google 加载了该文件,因此他们已经将其保存在缓存中。这样,您可以节省大量带宽,并且大多数访问者的页面加载速度更快。
您可以仅使用此 URL 来包含 api。 (更多信息)
This solution won't fix your permissions issue, but it's better to load the jQuery library from Google.
Google host several popular JS libraries.
The main advantage is that many people already loaded the file from Google, so they already have it in cache. This way, you save a lot of bandwidth, and pages load faster for most of your visitors.
You can just use this URL to include the api. (more info)