煎茶触摸和PHP的Webservice
目前,我正在学习煎茶触摸和作为一个测试,我写了一个小的web服务,我想在列表中显示煎茶触摸和PHP的Webservice
产生的项目,但我不能得到它的工作.. 。
Ext.define('GS.view.ListTest', {
extend: 'Ext.navigation.View',
requires:[
'Ext.dataview.List',
'Ext.data.proxy.JsonP',
'Ext.data.Store'
],
xtype:'listpanel',
config: {
title: 'Fifa List',
iconCls: 'star',
items: {
xtype: 'list',
itemTpl: '{Player1}',
store: {
autoLoad: true,
fields: ['MatchID','Player1', 'ScorePlayer1' ,'ScorePlayer2','Player2'],
proxy: {
type: 'jsonp',
url: 'http://fifa.verhulstrobin.be/webservices/getMatches.php',
reader: {
type:'json',
rootProperty: 'matches'
}
}
}
}
}
});
我检查,我的JSON是有效的... 所有它说,在控制台是未捕获的SyntaxError:意外的标记:
试试这个
items: {
xtype: 'list',
itemTpl: '{match.Player1}',
store:new Ext.create('Ext.data.Store', {
autoLoad: true,
fields: ['match'],
proxy: {
type: 'jsonp',
url: 'http://fifa.verhulstrobin.be/webservices/getMatches.php',
reader: {
type:'json',
rootProperty: 'matches'
}
})
}
}
新的Ext.create(...)??? – 2012-07-11 12:58:08
http://stackoverflow.com/questions/11209398/sencha-touch-2-store-typeerror/11209631#11209631 referr这个答案 – 2012-07-11 13:00:02
这是一个泄气的方法 – drew630 2012-07-12 01:17:12
尝试这样的事情,而不是:
items: {
xtype: 'list',
itemTpl: '{match.Player1}',
store: {
autoLoad: true,
fields: ['match'],
proxy: {
type: 'jsonp',
url: 'http://fifa.verhulstrobin.be/webservices/getMatches.php',
reader: {
type:'json',
rootProperty: 'matches'
}
}
}
}
希望这有助于
仍然返回相同的错误,无论如何感谢 – SnK 2012-07-11 11:33:54
好的,我会试一下 – 2012-07-11 12:58:37
在你的web服务响应的样子,我注意到,它不换行的JSON答案在函数调用像JSONP需要。你需要返回一个项目是这样的:
Ext.data.JsonP.callback1({});
其中,函数的参数必须是实际的JSON数据,而不是一个空的对象,函数“Ext.data.JsonP.callback1”的名字作为参数由Ext Store传递给您的webservice,名称为“callback”。
但是,您可以自定义参数的名称与callbackKey对代理:
var store = Ext.create('Ext.data.Store', {
model: 'User',
proxy: {
type: 'jsonp',
url : 'http://domainB.com/users',
callbackKey: 'theCallbackFunction' // <--
}
});
有关详细信息JSONP以及如何实现它的Ext JS的商店,你可以参考http://en.wikipedia.org/wiki/JSONP 和http://docs.sencha.com/touch/2-0/#!/api/Ext.data.proxy.JsonP
您正在使用JSONP代理的任何特定reaxon?你不能只使用Ajax代理吗? – 2012-07-12 20:39:44