JQuery问题"TypeError:$ .getJSON不是函数"

Gab*_*lla 30 javascript jquery slim-jquery

我有这段代码:

$(document).ready(function () {
    $.getJSON('http://localhost:5000/', function (response) {
        console.log(response);
    });
});
Run Code Online (Sandbox Code Playgroud)

localhost:5000是一个flask/python返回json类似的脚本:

{
  "data": [
    0, 
    0, 
    0, 
Run Code Online (Sandbox Code Playgroud)

我得到了:

$.getJSON is not a function TypeError: $.getJSON is not a function
Run Code Online (Sandbox Code Playgroud)

我可以开始解开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>
Run Code Online (Sandbox Code Playgroud)

lib/main.js是它的document.ready位置.

谢谢!

Aru*_*una 109

你似乎使用的slim版本jquery没有这个方法,getJSON这就是你得到这个错误的原因.

请使用jquery以下链接的完整版本.

https://code.jquery.com/jquery-3.1.1.min.js

Slim版本jquery排除ajax,animations effects