我想从谷歌加载jQuery,但总是无法加载.我的源代码有什么问题?
错误
(X) GET file://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js
Run Code Online (Sandbox Code Playgroud)
码
<!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>
Run Code Online (Sandbox Code Playgroud)
这是因为您在本地测试文件.
更改
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/jquery-ui.min.js"></script>
Run Code Online (Sandbox Code Playgroud)
至
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/jquery-ui.min.js"></script>
Run Code Online (Sandbox Code Playgroud)
添加评论@Ennui
要解释一下,//是一个协议相对url,所以在localhost上它将被解释为file://,在http http://和SSL之上https://.这在组合http和https协议的站点上很有用,但在本地开发站点上使用时会让人感到困惑.