无法访问spotify对象

时间:2015-03-15 17:40:58

标签: ajax asp.net-mvc api spotify

我想显示我从api控制器传递的艺术家的专辑 请求是here。 我可以访问info对象,但是当我访问albums对象时,它返回undefined

<script>
$(function () {
    $('table tr').click(function () {
        var id = this.id;
        $.ajax({
            type: "GET",
            url: '/api/author/GetName/' + id,
            contentType: "text/plain charset-utf-8",
            data: id,
            dataType: "json",
            success: function (data) {
                getDetails(data.name);

            }
        });
        }

    );
});//End ready
function getDetails(art) {
    $.ajax({
        type: "GET",
        url: 'http://ws.spotify.com/search/1/track.json?q='+ art ,
        dataType: 'json',
        success: function (data) {

            $('#summaryDisplay').empty();
            $('#summaryDisplay').append((JSON.stringify(data.albums)) + '<br/>');

            alert(JSON.stringify(data.info));
        },
        error: function (data) {
            $('#summaryDisplay').html('<h3>Error in retrieval</h3>');
        }
    });
}

1 个答案:

答案 0 :(得分:1)

您正在访问代码中的错误网址。使用album代替track

{
    // [...]
    url: 'http://ws.spotify.com/search/1/album.json?q='+ art,
    // [...]
}
相关问题