Answer the question
In order to leave comments, you need to log in
Displaying API information via getJSON if there is not always complete information inside?
Hello. Help solve the problem.
There is one service that provides an API via JSON
. The content looks like this:
{"gallery":{"kadr":[{"image":"инфа"},{"image":"инфа"},{"image":"инфа"},{"image":"инфа"},{"image":"инфа"},{"image":"инфа"},{"image":"инфа"},{"image":"инфа"},{"image":"инфа"},{"image":"инфа"}]}}
$.getJSON('ССЫЛКА',{},function (data,b,c){
document.getElementById("kadri").innerHTML=" <img src='ссылка"+data.gallery.kadr[0].image+"'> <img src='ссылка"+data.gallery.kadr[1].image+"'> <img src='ссылка"+data.gallery.kadr[2].image+"'> <img src='ссылка"+data.gallery.kadr[3].image+"'> <img src='ссылка"+data.gallery.kadr[4].image+"'> <img src='ссылка"+data.gallery.kadr[5].image+"'> <img src='ссылка"+data.gallery.kadr[6].image+"'> <img src='ссылка"+data.gallery.kadr[7].image+"'> <img src='ссылка"+data.gallery.kadr[8].image+"'> <img src='ссылка"+data.gallery.kadr[9].image+"'> ";
});
{"gallery":{"kadr":[{"image":"инфа"},{"image":"инфа"},{"image":"инфа"}]}}
Answer the question
In order to leave comments, you need to log in
$.getJSON('ССЫЛКА',{},function (data) {
var html = '';
data.gallery.kadr.forEach(function(element) {
html += '<img src="ссылка' + element.image + '">';
})
document.getElementById("kadri").innerHTML=html;
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question