先贴一段在网上看到的代码
在新发布的Ext3.0中,对Ext.lib.Ajax进行了改写,导致无法直接访问其内部的getConnectionObject方法,这对我们自己写同步请求方法带来困难,下面共享一个改写后的Ext3.0的同步请求方法:
//同步请求
Boat.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 != '') {
return Ext.decode(conn.responseText);
} else {
return null;
}
};
使用方法 var obj = Boat.Synchronize(url);