M
M
midarovrk2016-08-03 23:47:38
JavaScript
midarovrk, 2016-08-03 23:47:38

API where is the error?

Hello.
Can't get nameEN from API
Need to get nameEN":"The Death and Life of John F. Donovan" and "nameEN":"Adele: Hello"

{"peopleID":"1595490","webURL":"http:\/\/www.kinopoisk.ru\/name\/1595490\/","nameRU":"\u0410\u0434\u0435\u043b\u044c","nameEN":"Adele","sex":"female","posterURL":"actor_iphone\/iphone_1595490.jpg","growth":175,"birthday":"05.05.1988","age":"28","birthplace":"\u041b\u043e\u043d\u0434\u043e\u043d, \u0410\u043d\u0433\u043b\u0438\u044f, \u0412\u0435\u043b\u0438\u043a\u043e\u0431\u0440\u0438\u0442\u0430\u043d\u0438\u044f","filmography":[[{"filmID":843066,"professionText":"\u0410\u043a\u0442\u0440\u0438\u0441\u0430","professionKey":"actor","nameRU":"\u0421\u043c\u0435\u0440\u0442\u044c \u0438 \u0436\u0438\u0437\u043d\u044c \u0414\u0436\u043e\u043d\u0430 \u0424. \u0414\u043e\u043d\u043e\u0432\u0430\u043d\u0430","nameEN":"The Death and Life of John F. Donovan","year":"2017"},{"filmID":960434,"professionText":"\u0410\u043a\u0442\u0440\u0438\u0441\u0430","professionKey":"actor","nameRU":"","nameEN":"Adele: Hello (\u0432\u0438\u0434\u0435\u043e)","year":"2015"}],

I do it like this:
$.getJSON('ссылка на API',{},function (data) {
var html = '<style>мои стили</style>';
data.filmography.forEach(function(element) { 
html += '<a href="ссылка' +element.nameEN+ '">' +element.nameEN+ '</a>';
})
document.getElementById("myblock").innerHTML=html;
});

But it produces undefined undefined
What's wrong?

Answer the question

In order to leave comments, you need to log in

[[+comments_count]] answer(s)
D
DevMan, 2016-08-03
@midarovrk

show the full json, not the cut.
well, if you use jquery, then write something like:

$.each( data, function( key, val ) {
    html += '<a href="ссылка' +val.nameEN+ '">' +val.nameEN+ '</a>';
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question