weixin_33724659 2015-03-15 21:27 采纳率: 0%
浏览 29

数组中的JSON数组

im working with a JSON object here, i want to access the images, its an array within the array of 'results'. I know i have to loop, but not sure if im doing it correctly

enter image description here

My Code

function getVideos(art) {
    $.ajax({
        type: "GET",
        url: 'http://imvdb.com/api/v1/search/videos?q=' + art,
        dataType: 'json',
        success: function (data) {
            //alert(JSON.stringify(data.albums.name));
            $('#videos').empty();
            $.each(data.results.image, function (index, element) {
                //alert(element.name);
                $('#videos').append(element.results.image+ '<br/>');

            });
        },
        error: function (data) {
            $('#videos').html('<h3>Error in retrieval</h3>');
        }
    });

}

UPDATE when i just code

 $.each(data, function (index, element) {
                //alert(element.name);
                $('#videos').append(element.results+ '<br/>');

            });

i get enter image description here

UPDATE:

it works for me now i just was accessing results instead of images

$.each(data.results, function (index, element) {
                //alert(element.name);
                $('#videos').append(element.image.o + '<br/>');

            });
  • 写回答

2条回答 默认 最新

  • weixin_33743703 2015-03-15 22:04
    关注

    UPDATE:

    it works for me now i just was accessing results instead of images

    $.each(data.results, function (index, element) {
                    //alert(element.name);
                    $('#videos').append(element.image.o + '<br/>');
    
                });
    
    评论

报告相同问题?