Javascript 在下面的get.json中从上面的get.json接收数据

Javascript 在下面的get.json中从上面的get.json接收数据,javascript,json,itunes,getjson,Javascript,Json,Itunes,Getjson,我正试图从Itunes的json数据中显示我电台上歌曲的相册照片。但是,我不知道如何从上面的get.Json数据中检索我的无线电数据 function getStreamDetails() { $.ajaxSetup({cache: false}); $.getJSON('https://stream.livexenon.net/api/nowplaying_static/spacenl_radio.json', function (data) { var dj

我正试图从Itunes的json数据中显示我电台上歌曲的相册照片。但是,我不知道如何从上面的get.Json数据中检索我的无线电数据

function getStreamDetails() {
    $.ajaxSetup({cache: false});
    $.getJSON('https://stream.livexenon.net/api/nowplaying_static/spacenl_radio.json', function (data) {
        var dj = data['live']['streamer_name'] === '' ? 'Auto DJ' : data['live']['streamer_name'];

        $('#dj').html(dj);
        $('#listeners').html(data['listeners']['current']);
        $('#song').html(data['now_playing']['song']['text']);
        song = data['now_playing']['song']['text'];

});

// ALBUM IMAGE
$.getJSON("https://itunes.apple.com/search?term="+song+"&limit=1&media=music&entity=song&callback=?", function (data_foto) {
    var icon = document.getElementById("afbeelding");
    icon.src = data_foto.results[0].artworkUrl100;
});

}

setInterval(getStreamDetails, 10000);
getStreamDetails();
你有什么想法/解决方案给我吗


提前谢谢

您可以将所需变量移出
getStreamDetails
到外部范围,或者将第二个
$.getJSON
(位于下方)移动到
getStreamDetails
函数。在这种情况下,您将可以访问必要的数据