I have json data being fed into a Sencha touch app. Here's the json:

我将json数据输入到Sencha触摸应用程序中。这是json:

http://pastie.org/2622260 - (modified for an example, of course)

http://pastie.org/2622260 - (当然是为一个例子而修改)

When I return the "images" and console.log it, it returns the following:

当我返回“images”和console.log时,它返回以下内容:

images: "[object Object],[object Object],[object Object],[object Object],[object Object]"

Rather than the URLs.

而不是URL。

My json encoder looks like this (I'm pulling the data out of a Wordpress site):

我的json编码器看起来像这样(我从Wordpress站点中提取数据):

 case 'posts':
    foreach(get_posts('numberposts=50&category=') as $post) {

            $count = 0;
            $imgurl = array();
            foreach( get_group('Photo', $post->ID) as $images){
                $count++;
                $imgurl[] = array(
                    'count'=>$count,
                    'imageurl'=>get('photo_image_file', $count, 1, false, $post->ID),
                );
            }

      $json['posts'][] = array(
        'id'=>$post->ID,
        'title'=>$post->post_title,
        'body'=>apply_filters('the_excerpt', $post->post_content),
        'date'=>$post->post_date,
        'user'=>get_userdata($post->post_author)->user_firstname,            
    'images'=>$imgurl
      );

    }
}

    header('Content-type: application/json');

    echo json_encode($json);
    exit();

What I am looking for it to do is to return the array of image urls, rather than the [object object] that I am currently getting.

我正在寻找的是返回图像网址数组,而不是我目前得到的[对象对象]。

EDIT: Here is the sencha code I'm using to try to pull the imageurl out:

编辑:这是我用来尝试拉出图像的sencha代码:

    console.log(this.record.data);

    console.log(this.record.data.images);
    console.log(this.record.data.images.length);

    var numberOfPages = this.record.data.images.length;
    // Create pages for the carousel
    var pages = [];
    for (var i=0; i<numberOfPages; i++) {
        pages.push(new Ext.Component({
            id: 'page'+i,
            cls: 'page',
            tpl: '<tpl for=".">{imageurl}</tpl>',
            //html:'test',
        }));
    }

    // Create the carousel
    this.carousel = new Ext.Carousel({
        id: 'carousel',
        title:'Gallery',
        iconCls:'photos2',
        defaults: {
            cls: 'card'
        },
        items: pages,
    });

4 个解决方案

#1


1

Update: Sorry, for the irrelevant example I had given

更新:对不起,对于我给出的不相关的例子

Where is your pages[i].update(this.record.data.images); ?

你的网页在哪里[i] .update(this.record.data.images); ?

You can try the following -

您可以尝试以下方法 -

var numberOfPages = this.record.data.length;
// Create pages for the carousel
var pages = [];
for (var i=0; i<numberOfPages; i++) {
    var tmp = new Ext.Component({
        id: 'page'+i,
        cls: 'page',
        tpl: '<tpl for=".">{imageurl}</tpl>'
    });
    tmp.update(this.record.data[i].images);
    pages.push(tmp);
}

更多相关文章

  1. Python学习/复习神器-->各种方法/技巧在哪用和典型例子(一)
  2. Python 浅拷贝和深拷贝使用例子
  3. python打印列表的下标和值的例子:
  4. python2.7练习小例子(十二)
  5. 创建链表的小例子
  6. LNMP(Linux+Nginx+Mysql+PHP)环境下安装yaf框架并编写一个MVC例子
  7. 简单统计报表例子(存储过程)
  8. unity连接数据库MySQL简单例子
  9. webgote的例子(6)SQL注入(盲注)

随机推荐

  1. PHP生成圆心图片-常用作头像圆图等场景
  2. hust校赛d题 PHP is the best language i
  3. 存储用户所需语言的最佳方式
  4. PHP中使用cURL实现Get和Post请求的方法
  5. 一些PHP相关的数据比较
  6. Windows7搭建Apache本地服务器+PHP环境
  7. 如何为$ wpdb-> insert创建一个包含colum
  8. 为什么cron工作不是从浏览器工作,但从终端
  9. php连接mysql的三种方法
  10. 如何递归将特色图像应用于Wordpress中的