저는 Sencha 뷰에서 아무 것도 얻지 못하는 이유를 이해하기 위해 애 쓰고 있습니다. 나는 json이 서버와 Sencha 프록시 사이에서 전송되는 문제가 있다고 생각한다. 나는 Sencha에서 노드와 익스프레스와 프록시 리더로 코딩 된 서버를 가지고있다. 그러나 Sencha는 데이터를 읽을 수 없습니다.JSON 응답 : 노드 서버와 Sencha
서버 측 :
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));
}
)};
});
센차보기 : 크롬에서
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"}]});
그러나 아무것도 뷰에 나타납니다.
또한 JSONP 유형이 필요합니까? 당신은 십자가 sripting을 사용할 것인가? 귀하의 회신에 감사드립니다. – Psycho