0

Uncaught ReferenceError: $ is not defined
at gettodo (script.js:4)
at script.js:13

No one can fix my error problem. The entire HTML file is here:

<html>
  <head></head>
  <div id="3rd_title_here"></div>
  <script src="script.js"></script>
</html>

entire script.js code here

function gettodo() {
    var TODOS ='https://jsonplaceholder.typicode.com/todos';
    $.ajax({
        cache: false,
        dataType: "json",
        url: TODOS,
        success: function(data) {  
          $('#3rd_title_here').html(data[2].title);
        }
    });
}
setInterval(gettodo(),1000);

im just trying to display the 3rd title on the json

{
  "userId": 1,
  "id": 1,
  "title": "delectus aut autem",
  "completed": false
}, {
  "userId": 1,
  "id": 2,
  "title": "quis ut nam facilis et officia qui",
  "completed": false
},{
  "userId": 1,
  "id": 3,
  "title": "fugiat veniam minus", // <--- im trying to display this guy
  "completed": false
}
Rory McCrossan
  • 331,213
  • 40
  • 305
  • 339
lee sin
  • 3
  • 3

0 Answers0