jQuery库无法从谷歌加载

时间:2014-01-22 19:53:36

标签: jquery

我想从Google加载jQuery,但总是无法加载。我的源代码有什么问题?

错误

(X) GET file://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js  

CODE

<!DOCTYPE html>
<head>
    <meta charset="utf-8">
    <meta content='IE=8' http-equiv='X-UA-Compatible'>
    <meta name="viewport" content="initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" type="text/css" href="">
    <title></title> 
</head>
<body>
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
    <script>console.log($('body').height());</script>
</body>
</html>

1 个答案:

答案 0 :(得分:8)

这是因为您在本地测试文件。

更改

<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/jquery-ui.min.js"></script>

<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/jquery-ui.min.js"></script>

添加评论@ Ennui

要解释一下,//是协议相对网址,因此在localhost上它将被解释为file://,http将被解释为http://,而SSL将被解释为https://。这在组合了http和https协议的站点上很有用,但在本地开发站点上使用时会让人感到困惑。