使用JSON数组和对象

时间:2018-04-28 22:52:14

标签: jquery arrays json

我有json data here。我正试图在property_more_images中获取数据:

getItemImages: function(pid) {
    xhr.simpleCall({
        query:{ 
            com_option:"item",
            item_get_id:pid
        },
        func:'timeline'
    }, function(response) { 
           if (response.err_code === 0) { 
               console.log(response.data[0].property_more_images);

               var arr = response.data[0].property_more_images;

               notice_obj = [];
               for (var i = 0, l = arr.length; i < l; ++i) {
                   notice_obj.push(arr[i]);                               
               }

               return notice_obj.join(' ,');
           }  
       });
}

然后像这样使用getItem函数:

getItem: function(pid) {
    var $this = $$('.time-line-content .item-content[data-id="'+ pid +'"]');
    var item = {
        id: $this.data('id'),
        nickname: $this.find('.item-header .detail .nickname').html()
    };

    item.propslider = this.getItemImages(pid);

    var output = TM.renderTplById('itemTemplate', item);

    $$('#itemContent').html(output);
}

到目前为止,我的console.log给了我预期的json数据。当我在getItemImages函数中调用getItem函数时,我似乎无法获取任何数据。 getItemImages函数有问题。我无法弄清楚是什么。

1 个答案:

答案 0 :(得分:0)