Gabriel A. Zorrilla Gabriel A. Zorrilla - 25 days ago 28
Javascript Question

$.getJSON is not a function TypeError: $.getJSON is not a function

I've got this piece of code:

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


localhost:5000 is a flask/python script that returns a json like:

{
"data": [
0,
0,
0,


And i'm getting:

$.getJSON is not a function TypeError: $.getJSON is not a function


Any tips where i can start untangling the whoolball?

Thanks!

Edit:

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 is where the document.ready is located.

Thanks!

Answer

You seem to be using slim version of jquery which does not have the method getJSON thats why you are getting this error.

Please use the full version of jquery instead from the below link.

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

Slim version of jquery excludes ajax, animations effects etc