M
M
midarovrk2016-09-01 19:54:42
JavaScript
midarovrk, 2016-09-01 19:54:42

How to get all the information from the array using getJSON?

Hi, can you tell me what's wrong?

There is such an API array - mytest.ucoz.org/test.html
I need to get all nameEN and all year from this array.
I do this:

<div id="myblok"></div>

<script type="text/javascript">
$.getJSON('здесь ссылка на API',{},function (data) {
var html = '';
data.previewFilms[0].forEach(function(element) { 
html += ' <div>'+element.nameEN+'</div> <div>'+element.year+'</div> ';
})
document.getElementById("myblok").innerHTML=html;
});
</script>

It works, but it pulls out only the last part, and not everything in this array. Pulls from Jason Bourne to Sul vulcano.
How can I extract absolutely all nameEN and year?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Skogorev, 2016-09-01
@midarovrk

data.previewFilms.forEach

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question