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/>');
    
                });
    
    评论

报告相同问题?

悬赏问题

  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置