[英]Working with JSON arrays and objects
I have json data here . 我这里有json数据 。 I am trying to get data in
property_more_images
like this: 我试图像这样在
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(' ,');
}
});
}
and then use the getItem
function later like this: 然后像下面这样使用
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);
}
So far my console.log
gives me json data as I expect. 到目前为止,我的
console.log
给了我期望的json数据。 When I call the getItemImages
function inside the getItem
function, I don't seem to get any data. 当我在
getItem
函数中调用getItemImages
函数时,似乎没有任何数据。 Something is wrong with the getItemImages
function. getItemImages
函数出了点问题。 I am not able to figure out what. 我不知道是什么。
在带有ajax的Javascript回调函数的一些指导下
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.