Node.js JSON响应:节点服务器和Sencha
我很难理解为什么我在Sencha视图中什么都看不到。我认为服务器和Sencha代理之间传输的json存在问题。我有一个用node和express编码的服务器,还有一个用Sencha编码的代理读取器。但Sencha无法读取数据 服务器端:Node.js JSON响应:节点服务器和Sencha,node.js,extjs,express,Node.js,Extjs,Express,我很难理解为什么我在Sencha视图中什么都看不到。我认为服务器和Sencha代理之间传输的json存在问题。我有一个用node和express编码的服务器,还有一个用Sencha编码的代理读取器。但Sencha无法读取数据 服务器端: app.get('/weather/fulljson',function(req, res) { var obj = {data: [{ from_user: 'world', data: 'inter' }, { from_user: 'wo
app.get('/weather/fulljson',function(req, res) {
var obj = {data: [{ from_user: 'world', data: 'inter' }, { from_user: 'world2', data: 'interw' }, { from_user: 'world3', data: 'interw' }]};
jsonP = false;
var cb = req.query.callback;
console.log(cb);
if (cb != null) {
jsonP = true;
res.writeHead(200, {
'Content-Type': 'text/javascript',
'connection' : 'close'
});
} else {
res.writeHead(200, {'Content-Type': "application/x-json"});
}
if (jsonP) {
res.end(cb + "(" + JSON.stringify(obj) + ");" );
}
else { res.end(JSON.stringify(obj));
}
)};
});
Sencha观点:
Ext.define('Epic.view.Weather', {
xtype: 'graph',
extend: 'Ext.DataView',
//requires: ['Epic.store.SWeather'],
requires: ['Epic.model.MWeather', 'Ext.data.proxy.JsonP'],
config: {
store: {
autoLoad: true,
fields: ['from_user', 'data'],
proxy: {
type: 'jsonp',
url: 'http://localhost:3000/weather/fulljson',
reader: {
type: 'json',
rootProperty: 'data'
}
}
}
},
itemTpl: '{from_user}'
});
铬的响应:
Ext.data.JsonP.callback1({"data":[{"from_user":"world","data":"inter"},{"from_user":"world2","data":"interw"},{"from_user":"world3","data":"interw"}]});
但是视图中没有显示任何内容。加载后是否检查了您的店铺?它是否包含您发送的数据?如果是-在这种情况下,你的观点有问题。您可以使用调试器工具获取组件并检查存储。
你也可以展示你的Epic.model.MWeather模型吗?实际上,如果您有模型,则不必向应用商店添加字段。谢谢您的回复。如何在不使用DataView的情况下检查存储是否有数据?感谢您的回复。我现在不使用这个模型。如果我移除它,一切都不会改变。在检查商店时,您是否在谈论“资源”选项卡和本地存储?如果它正常工作,应该显示什么?您可以使用Ext.getCmp('id')和可以从DOM获得的id。此外,您需要JSONP类型吗?您将使用跨站点脚本吗?