jQuery问题"TypeError:$.getJSON不是函数" [英] JQuery issue "TypeError: $.getJSON is not a function"
本文介绍了jQuery问题"TypeError:$.getJSON不是函数"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这段代码:
$(document).ready(function () {
$.getJSON('http://localhost:5000/', function (response) {
console.log(response);
});
});
localhost:5000是一个flask/python
脚本,它返回一个json
,如:
localhost:5000 is a flask/python
script that returns a json
like:
{
"data": [
0,
0,
0,
我得到了:
$.getJSON is not a function TypeError: $.getJSON is not a function
有什么秘诀可以让我开始搞乱杂音吗?
Any tips where I can start untangling the whoolball?
谢谢!
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
的slim
版本,该版本没有方法getJSON
,这就是为什么出现此错误的原因.
You seem to be using slim
version of jquery
which does not have the method getJSON
thats why you are getting this error.
请使用完整版的jquery
,而不是下面的链接.
Please use the full version of jquery
instead from the below link.
https://code.jquery.com/jquery-3.1.1.min.js
Slim
版本的jquery
不包括ajax
,animations effects
等
这篇关于jQuery问题"TypeError:$.getJSON不是函数"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文