【发布时间】:2016-11-15 01:01:11
【问题描述】:
我有这段代码:
$(document).ready(function () {
$.getJSON('http://localhost:5000/', function (response) {
console.log(response);
});
});
localhost:5000 是一个flask/python 脚本,它返回一个json,例如:
{
"data": [
0,
0,
0,
我得到:
$.getJSON is not a function TypeError: $.getJSON is not a function
有什么技巧可以让我开始解开滚球吗?
谢谢!
编辑:
HTML:
<!DOCTYPE html>
<html>
<head>
<script src="https://code.jquery.com/jquery-3.1.1.slim.min.js"></script>
<script src="lib/main.js"></script>
</head>
<body>
</body>
</html>
lib/main.js 是document.ready 所在的位置。
谢谢!
【问题讨论】:
-
您的页面上加载了哪些脚本?你要么不包括
jQuery,要么在此之前的某个时间点调用了jQuery.noConflict()(这意味着从那时起你必须使用jQuery而不是$。 -
如果他没有加载 jQuery,他会在 $(document) 上得到一个错误($ not found 或其他东西)...所以它可能是 noConflict...
-
你的 html 没有检测到你的 jquery 库
-
@GabrielA.Zorrilla 请在下面的答案中查看我的建议。
标签: javascript jquery slim-jquery