Sencha Touch 和 WordPress BuddyPress API 之间的 JSON 解析问题
Posted
技术标签:
【中文标题】Sencha Touch 和 WordPress BuddyPress API 之间的 JSON 解析问题【英文标题】:JSON parsing issue between Sencha Touch and WordPress BuddyPress API 【发布时间】:2013-01-13 20:56:52 【问题描述】:我是 Sencha Touch 的新手,我正在尝试找出对 WordPress 的 JSON 调用。我在服务器端的 WordPress 上使用 JSON-API-for-BuddyPress 插件。
http://www.erefer.me/api/buddypres-s-read/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/buddypres-s-read/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 的设置方式与其他字段不同,但我不确定。我错过了什么?
【问题讨论】:
【参考方案1】:JSONP 需要一个围绕响应的“包装器”函数。在这种情况下,它将作为请求的一部分传递,例如 callback=Ext.data.JsonP.callback1
见:parsererror after jQuery.ajax request with jsonp content type
【讨论】:
以上是关于Sencha Touch 和 WordPress BuddyPress API 之间的 JSON 解析问题的主要内容,如果未能解决你的问题,请参考以下文章
来自 JSON 商店的 Sencha Touch Carousel
Sencha Touch - sencha touch js 大小的性能问题
Sencha Touch实战OA系统开发|Sencha Touch项目教程
[Sencha ExtJS & Touch] 在Sencha(Extjs/Touch)应用程序中使用plugins(插件)和mixins(混入)