引入以下扩展:(<script src="Scripts/Ext.lib.Ajax.getConnectionObject.js"></script>)
Ext.lib.Ajax.getConnectionObject = function() {
var activeX = ['MSXML2.XMLHTTP.3.0', 'MSXML2.XMLHTTP', 'Microsoft.XMLHTTP'];
function createXhrObject(transactionId) {
var http;
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 {
conn : http,
tId : transactionId
};
}
}
var o;
try {
if (o = createXhrObject(Ext.lib.Ajax.transactionId)) {
Ext.lib.Ajax.transactionId++;
}
} catch (e) {
} finally {
return o;
}
};
调用方法:
Ext.onReady(function() {
var conn = Ext.lib.Ajax.getConnectionObject().conn;
conn.open("POST", 'data_request', false);
var param = {
name : 'wzp',
age : 28
};
conn.send(Ext.encode(param));
alert(conn.responseText);
});