我試圖強制ExtJS和Java之間的通信我正在從ExtJS發送請求到使用netty的Java服務器。如果有人能夠給我一個例子,說明如何從java方面編寫響應,以及如何從ExtJS方面提前讀取響應數據,我會感到滿意。 這是從ExtJS的側ExtJS JsonStore和Netty
var store = new Ext.data.JsonStore({
autoload: true,
baseParams: {
conid : '6b09477f-aa04-4f5a-b969-05277d01f07e'
},
root: 'OpenCashTime',
proxy: new Ext.data.ScriptTagProxy({
url: 'http://localhost:8080/getOpenCash?'
}),
fields: [{name: 'Time', mapping: 'Time', type: 'int'}]
});
store.load();
store.on('load', function() {
alert(store.getTotalCount());
});
store.on('write', function() {
alert(store.getTotalCount());
});
store.on('loadexception', function() {
alert("AAAAAA");
});
store.on('metachange', function() {
//alert(store.getTotalCount());
});
store.on('update', function() {
//alert(store.getTotalCount());
});
store.on('save', function() {
//alert(store.getTotalCount());
});
store.on('datachanged', function() {
//alert(store.getTotalCount());
});
我的源代碼在執行這個代碼,並reciving這個響應{ 「OpenCashTime」:[{ 「時代」:1291623637000},{ 「時代」:1294914317000}]}我仍然得到即使螢火蟲看到它的Json
爲什麼選擇ScripTagProxy?你會從跨域來源加載數據嗎? – Mchl 2011-02-02 17:32:30
是的,現在我正在測試本地主機加上它不在同一臺服務器上運行的Apache Tomcat服務器上的ExtJS和netty部分運行在不同的端口,因此它被視爲跨域 – Swine1973 2011-02-02 17:35:51
好吧。對於ScriptTagProxy,您的響應必須如下所示:`callback({「OpenCashTime」:[{「Time」:1291623637000},{「Time」:1294914317000}]})`。 – Mchl 2011-02-02 17:40:36