获取第二个 .getJSON 的数据

问题描述

我有以下问题,我相信我已经对网站进行了编码以执行两次连续的 API 调用,但无法从第二次调用获取任何数据到我的 div 中。

$(document).ready(function() {
    $(".discogs-loading").show();
    $.getJSON("http://api.discogs.com/users/bengeorgebrooks/collection/folders/0/releases?callback=&sort=added&sort_order=desc&per_page=1000",function(data) {
        $(".discogs-loading").hide();
        if (data.pagination.items > 1) {
            $.each(data.releases,function(i,release) {
            $.getJSON("http://ws.audioscrobbler.com/2.0/?method=album.getinfo&api_key=cf59c4a923ea2f7743bd8899ec439581&artist=" + release.basic_information.artists[0].name + "&album=" + release.basic_information.title + "&format=json",function(data) {                    
            });
                content =
                    '<li class="folder"><div class="img"></div><a class="name" href="#">' + release.basic_information.artists[0].name + '</a><p class="type">' + release.basic_information.title + '</p><ul class="video_tags"><li class="tag1">' + release.basic_information.labels[0].name + ' ·</li><li class="tag2">' + release.basic_information.formats[0].descriptions[0] + ' ·</li><li class="tag3">' + release.basic_information.year + '</li></ul><ul class="video_tags"><li class="tag4">' + release.basic_information.genres[0] +  ' ·</li><li class="tag5">' + release.basic_information.styles[0] +  ' ·</li><li class="tag5">' + + '</li></ul><ul class="video_tags"><li class="tag6">10 Plays ·</li><li class="tag7"> 20th May 2021</li></ul><p class="pinned icon-pinned"><img src="last_fm.png" height="25px">&nbsp;&nbsp;&nbsp;<img src="heart.png" height="15px"></p></li>';
                $(content).appendTo("#discogs-collection");
            });
            $(".discogs-link").click(function() {
                window.open($(this).data("href"));
            });
        } else {
            $("#discogs-collection").append("<tr class='discogs-error'><td>Error! Something is up with the discogs API.</td></tr>");
        }
    });
});

我的期望是我应该能够通过 data.album.name 从 Last.FM 获取专辑名称,但这不起作用并且要么返回 undefined 要么只是阻止页面加载。

Last.FM API 结果示例

{"album":{"name":"Believe","artist":"Cher","mbid":"63b3a8ca-26f2-4e2b-b867-647a6ec2bebd","url":"https://www.last.fm/music/Cher/Believe","image":[{"#text":"https://lastfm.freetls.fastly.net/i/u/34s/3b54885952161aaea4ce2965b2db1638.png","size":"small"},{"#text":"https://lastfm.freetls.fastly.net/i/u/64s/3b54885952161aaea4ce2965b2db1638.png","size":"medium"},{"#text":"https://lastfm.freetls.fastly.net/i/u/174s/3b54885952161aaea4ce2965b2db1638.png","size":"large"},{"#text":"https://lastfm.freetls.fastly.net/i/u/300x300/3b54885952161aaea4ce2965b2db1638.png","size":"extralarge"},"size":"mega"},"size":""}],"listeners":"477539","playcount":"3311984","tracks":{"track":[{"name":"Believe","url":"https://www.last.fm/music/Cher/_/Believe","duration":"240","@attr":{"rank":"1"},"streamable":{"#text":"0","fulltrack":"0"},"artist":{"name":"Cher","mbid":"bfcc6d75-a6a5-4bc6-8282-47aec8531818","url":"https://www.last.fm/music/Cher"}},{"name":"The Power","url":"https://www.last.fm/music/Cher/_/The+Power","duration":"236","@attr":{"rank":"2"},{"name":"Runaway","url":"https://www.last.fm/music/Cher/_/Runaway","duration":"286","@attr":{"rank":"3"},{"name":"All or nothing","url":"https://www.last.fm/music/Cher/_/All+or+nothing","duration":"237","@attr":{"rank":"4"},{"name":"Strong Enough","url":"https://www.last.fm/music/Cher/_/Strong+Enough","duration":"223","@attr":{"rank":"5"},{"name":"Dov'e L'amore","url":"https://www.last.fm/music/Cher/_/Dov%27e+L%27amore","duration":"258","@attr":{"rank":"6"},{"name":"Takin' Back My Heart","url":"https://www.last.fm/music/Cher/_/Takin%27+Back+My+Heart","duration":"272","@attr":{"rank":"7"},{"name":"Taxi Taxi","url":"https://www.last.fm/music/Cher/_/Taxi+Taxi","duration":"304","@attr":{"rank":"8"},{"name":"love Is the Groove","url":"https://www.last.fm/music/Cher/_/love+Is+the+Groove","duration":"271","@attr":{"rank":"9"},{"name":"We All Sleep Alone","url":"https://www.last.fm/music/Cher/_/We+All+Sleep+Alone","duration":"310","@attr":{"rank":"10"},"url":"https://www.last.fm/music/Cher"}}]},"tags":{"tag":[{"name":"pop","url":"https://www.last.fm/tag/pop"},{"name":"90s","url":"https://www.last.fm/tag/90s"},{"name":"dance","url":"https://www.last.fm/tag/dance"},{"name":"cher","url":"https://www.last.fm/tag/cher"},{"name":"albums I own","url":"https://www.last.fm/tag/albums+I+own"}]},"wiki":{"published":"27 Jul 2008,15:55","summary":"Believe is the twenty-third studio album by American  singer-actress Cher,released on November 10,1998 by Warner bros. Records. The RIAA certified it Quadruple Platinum on December 23,1999,recognizing four million shipments in the United States; Worldwide,the album has sold more than 20 million copies,making it the biggest-selling album of her career. In 1999 the album received three Grammy Awards nominations including \"Record of the Year\",\"Best Pop Album\" and winning \"Best Dance Recording\" for the single \"Believe\". <a href=\"http://www.last.fm/music/Cher/Believe\">Read more on Last.fm</a>.","content":"Believe is the twenty-third studio album by American  singer-actress Cher,\"Best Pop Album\" and winning \"Best Dance Recording\" for the single \"Believe\".\n\nIt was released by Warner bros. Records at the end of 1998. The album was executive produced by Rob Dickens. Upon its debut,critical reception was generally positive. Believe became Cher's most commercially-successful release,reached number one and Top 10 all over the world. In the United States,the album was released on November 10,1998,and reached number four on the Billboard 200 chart,where it was certified four times platinum.\n\nThe album featured a change in Cher's music; in addition,Believe presented a vocally stronger Cher and a massive use of vocoder and Auto-Tune. In 1999,the album received 3 Grammy Awards nominations for \"Record of the Year\",\"Best Pop Album\" and winning \"Best Dance Recording\". Throughout 1999 and into 2000 Cher was nominated and winning many awards for the album including a Billboard Music Award for \"Female Vocalist of the Year\",Lifelong Contribution Awards and a Star on the Walk of Fame shared with former Sonny Bono. The boost in Cher's popularity led to a very successful Do You Believe? Tour.\n\nThe album was dedicated to Sonny Bono,Cher's former husband who died earlier that year from a skiing accident.\n\nCher also recorded a cover version of \"love Is in the Air\" during early sessions for this album. Although never officially released,the song has leaked on file sharing networks.\n\nSingles\n\n\n\"Believe\"\n\"Strong Enough\"\n\"All or nothing\"\n\"Dov'è L'Amore\" <a href=\"http://www.last.fm/music/Cher/Believe\">Read more on Last.fm</a>. User-contributed text is available under the Creative Commons By-SA License; additional terms may apply."}}}

谁能告诉我哪里出错了?

非常感谢,

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)