0

我是 Sencha Touch 的新手,我正在尝试找出对 WordPress 的 JSON 调用。我在服务器端的 WordPress 上使用 JSON-API-for-BuddyPress 插件。

http://www.erefer.me/api/buddypressread/groups_get_groups/?username=troy

{"status":"ok","groups":{"149":{"name":"Barakah Biz Network Referrals","description":"This group is for B.B.N members to send and receive their referrals online.  This way all members have an online record of their referrals and no worries of losing pieces of paper.  You can easily view your referrals and contact them while they are hot.  You can also send referrals to other members that are tracked for prizes.  \r\n\r\nTracking how much business we do with each other is the only way to determine how effective we are at supporting each other in building our communities businesses together.  Members of this group but be member of BBN Network.","status":"public","creator":{"202":{"username":"bbnnetwork","mail":"victoria@bbnnetwork.org","display_name":"bbnnetwork"}},"slug":"barakah-biz-network-referrals","is_forum_enabled":false,"date_created":"2012-12-19 16:15:38","count_member":"4"},"57":{"name":"Troy\\'s Public List of Referral Partners","description":"List of referral partners that I share with the public.","status":"public","creator":{"1":{"username":"troy","mail":"troy@eRefer.Me","display_name":"troy"}},"slug":"troys-public-list-of-referral-partners","is_forum_enabled":false,"date_created":"2012-10-10 00:50:34","count_member":"2"},"40":{"name":"Austin RainMakers","description":"RainMakers of Austin Group ","status":"private"},"1":{"name":"Troy\\'s Private Network","description":"Troy\\'s Private Referral Network","status":"private"}},"count":4}

该模型:

Ext.define('eReferMe.model.Group', {
extend: 'Ext.data.Model',
config: {
        grouper: function(record) {
            return record.get('name')[0];
        },
        fields: ['id',
                 'name', 
             'description', 
             'status',
             'creator',
             'slug',
             'is_forum_enabled',
             'date_created',
             'count_member'
            ],
            autoLoad: true,

        proxy: {
            type: 'jsonp',
        url: 'http://www.erefer.me/api/buddypressread/groups_get_groups/?username=troy',
        reader: {
                    type: 'json',
                    successProperty: 'status',
                    rootProperty: 'groups',
                    totalProperty: 'count'


                   }
         }
}

});

商店:

Ext.define('eReferMe.store.Groups', {
extend: 'Ext.data.Store',
config: {
    group: true,
    model: 'eReferMe.model.Group',
    sorters: 'name',
grouper : function(record) {
       return record.get('name')[0];
    }        

}  

});

我认为这可能与 ID 没有像其他字段那样设置的方式有关,但我不确定。我错过了什么?

4

1 回答 1

0

JSONP 需要一个围绕响应的“包装器”函数。在这种情况下,它将作为请求的一部分传递,例如callback=Ext.data.JsonP.callback1

请参阅:带有 jsonp 内容类型的 jQuery.ajax 请求后的 parsererror

于 2013-01-30T06:25:50.227 回答