简体   繁体   中英

Read data from JSON Url using plain javascript and display it in HTML

I need to read data from json generated url using plain javascript and display the data in html.i have searched alot but i couldn't find exactly what i need. Can you please give me some startup like what should i do to or any reference materials. I really want to learn and implement it on my own.

PS: I am a beginner in JavaScript.

You can use ES6 fetch API to load the request data and then render it.

fetch('http://example.com/movies.json')
  .then(function(response) {
    return response.json();
  })
  .then(function(myJson) {
    console.log(myJson);
  });

Here's a tutorial on fetch API: https://scotch.io/tutorials/how-to-use-the-javascript-fetch-api-to-get-data

Fetch is now supported in all modern browsers: https://caniuse.com/#feat=fetch

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM