开发者

Server not reading jquery

I created an applic开发者_运维问答ation using PHP, mysql, and jquery. It's working fine on my localhost,m however after uploading it to the server, everything works fine but jquery, I believe it's not reading it.

Using firebug, I get the following error when trying to read the .js file in the browser:

Uncaught syntax error: Unexpected token.

Here's how i include my scripts:

<script type="text/javascript" src="js/jquery-1.6.1.min.js"></script>
<script type="text/javascript" src="js/autoresize.jquery.js"></script>
<script type="text/javascript" src="js/customSelect.jquery.js"></script>
<script type="text/javascript" src="js/jquery.form.js"></script>
<script type="text/javascript" src="js/jquery.validate.js"></script>
<script type="text/javascript" src="js/jquery.validate.password.js"></script>

I did check my files and they exist in /js/ . What could be wrong?

UPDATE

It is working when I read : https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js

But it's not working when reading from server?


You are using relative path right now.

When you use relative path, all the requests will go to the path relative to your location.

For example, if you are on http://www.mysite.com/products/catalog.php, your browser will send the request to get the jQuery scripts from this location: http://www.mysite.com/products/js/ which certainly does not exists.

Try using the absolute path instead. In fact make a habit of!

Try the following:

<script type="text/javascript" src="/path/to/your/srcipt/jquery-1.6.1.min.js"></script>
<script type="text/javascript" src="/path/to/your/srcipt/autoresize.jquery.js"></script>
<script type="text/javascript" src="/path/to/your/srcipt/customSelect.jquery.js"></script>
<script type="text/javascript" src="/path/to/your/srcipt/jquery.form.js"></script>
<script type="text/javascript" src="/path/to/your/srcipt/jquery.validate.js"></script>
<script type="text/javascript" src="/path/to/your/srcipt/jquery.validate.password.js"></script>


Shoud be an HTTP GET request for these js file.

<script type="text/javascript" src="js/jquery-1.6.1.min.js"></script>

Sounds like it does not exist on the location. If you have nice urls implemented or file does not exist then it would not work, try using full path.

<script type="text/javascript" src="http://xyz.com/js/jquery-1.6.1.min.js"></script>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜