[英]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. 我需要使用普通的javascript从json生成的url中读取数据,并在html.display中显示数据。我已经搜索了很多,但我找不到我真正需要的。 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. PS:我是JavaScript的初学者。
You can use ES6 fetch API to load the request data and then render it. 您可以使用ES6提取API加载请求数据,然后进行呈现。
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 这是关于获取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 现在,所有现代浏览器均支持Fetch: https : //caniuse.com/#feat=fetch
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.