I have a JSON file which includes 3 images however I am struggling to find an example on how to get them to display on my web page using JavaScript. My JSON file includes :
{
"tiles" : [
{
"img" : "example1.jpg"
},
{
"img" : "example2.jpg"
},
{
"img" : "example3.jpg"
}
]
}
My HTML includes:
<div class="tile-image1"></div>
<div class="tile-image2"></div>
<div class="tile-image3"></div>
And I have retrieved my JSON data through:
var requestURL = "https://api.myjson.com";
var request = new XMLHttpRequest();
request.open('GET', requestURL);
request.responseType = 'json';
request.send();
So what I am trying to achieve is to display an "img" to the class "tile-image1", a second "img" to the class "tile-image2", etc. Any help would be great.