Quantcast
Channel: Active questions tagged html - Stack Overflow
Viewing all articles
Browse latest Browse all 73905

Uncaught TypeError: request.onload is not a function

$
0
0

there is a problem when I'm trying to view a json file in a consloe(chrome developers tools) it says uncaught type error request.onload is not a function, but I can't find where is the problem can anybody help thanks in advace

<html>
<head>
  <title>ajax php</title>
  <!--<link rel="stylesheet" href="css/style.css">-->
</head>
<body>
  <header>
    <h1> json and ajax</h1>
    <button id="btn">fet info from JSON file</button>
  </header>

  <div id="animal-info"></div>

  <script src="main.js"></script>
</body>
</html>


<!--this code is in a seperate file main,js-->
    enter code here
    var request = new XMLHttpRequest();
    request.open('GET', 'https://learnwebcode.github.io/json-example/animals-1.json');
    request.onload() = function() {
      var data = request.responseText;
      console.log(request.responseText);
    };
    request.send();

Viewing all articles
Browse latest Browse all 73905

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>