一个页面由多个组件组成,每个组件都重后台取数据,使用Ext.Ajax.request()方式
Ext.Ajax.request(
{
url : 'rightAction!methodXX1.action',
}
)Ext.Ajax.request(
{
url : 'rightAction!methodXX2.action',
}
)Ext.Ajax.request(
{
url : 'rightAction!methodXX3.action',
}
)
经常1的数据显示在2上,或2的数据显示在3上。
后来把Ext.Ajax.request改为同步方式解决。但同步执行会影响效率,失去ajax的优点。郁闷中……
问题补充:
谢谢boreas_baosj
其实我已经使用同步方法解决了。其实我最主要的是和FusionCharts结合使用。
本来 有setDataURL(XX.action),不能使用,只能使用。
就是感觉有点别扭。
Wsd.web.chart = function() {
var w = 100;
var h = 230;
var obj = document.getElementById('web-area-container');
w = obj.offsetWidth;
w = w / 3;
// 区域
this.showChart(w, h, 'wtoEMsColAction!GZtoGD.action', 'GZtoGD',
'MSColumn3D.swf');
this.showChart(w, h, 'wtoEMsColAction!YNtoGD.action', 'YNtoGD',
'MSColumn3D.swf');
this.showChart(w, h, 'wtoEMsColAction!GXtoGD.action', 'GXtoGD',
'MSColumn3D.swf');// 地域 var obj = document.getElementById('web-factory-container'); w = obj.offsetWidth; w = w / 3; this.showChart(w, h, 'wtoEMsColAction!tianYi.action', 'tianYi', 'MSColumn3D.swf'); this.showChart(w, h, 'wtoEMsColAction!tianEr.action', 'tianEr', 'MSColumn3D.swf'); this.showChart(w, h, 'wtoEMsColAction!longTan.action', 'longTan', 'MSColumn3D.swf');
}
Wsd.web.chart.prototype = {
showChart : function(w, h, url, chartId, swf) {
var xmlStr = Wsd.golob.Synchronize(url);
var chart = new FusionCharts('../scripts/fusionCharts/swf/' + swf,
chartId + '_flash', w, h, '0', '0');
chart.setDataXML(xmlStr);
chart.setTransparent(true);
chart.render(chartId);
}}
//自己定义一个同步的方法。作为全局的方法使用
Wsd.golob.Synchronize = function(url) {
function createXhrObject() {
var http;
var activeX = ['MSXML2.XMLHTTP.3.0', 'MSXML2.XMLHTTP',
'Microsoft.XMLHTTP'];
try {
http = new XMLHttpRequest();
} catch (e) {
for (var i = 0; i < activeX.length; ++i) {
try {
http = new ActiveXObject(activeX[i]);
break;
} catch (e) {
}
}
} finally {
return http;
}
};var conn = createXhrObject(); conn.open("GET", url, false); conn.send(null); if (conn.responseText != '') { var returnVal=conn.responseText; if (returnVal.indexOf("Session Expired") != -1) {//判断session超时 new Wsd.golob.Redirect(); } else { return returnVal; } } else { return null; }
};