1. Ext.Ajax (extends Connection)
Ext.Ajax.on("requestcomplete", function(_conn, _response,
_options) {
alert(_response.responseXML.xml);
});
Ext.Ajax.request({
url : "http://localhost:8080/extjs/servlet/TestServlet",
params : {
name : "aaa",
sex : "bbb"
}
})
_response.responseText
method: get post
参数也可以是xml格式的数据
Ext.Ajax.request({
url : "http://localhost:8080/extjs/servlet/TestServlet",
method : "post",
xmlData: "<?xml version=\"1.0\" encoding=\"GB2312\"?><aaa></aaa>"
});
Json数据格式
Ext.Ajax.request({
// dataType : "json",
url : "http://localhost:8080/extjs/servlet/TestServlet",
method : "post",
jsonData : {name:"name",sex:"sex"}
});
2. Ext.data.Connection (extends Connection)
Ext.onReady(function() {
var _window = new Ext.Window({
title : "登录",
frame : true,
width : 500,
height : 400,
// layout : "form",
plain : true,
resizable : false,
bodyStyle : "padding:3px",
labelWidth : 45,
minimizable : false,
maximizable : false,
closable : true,
closeAction : "hide",
buttonAlign : "left",
items : [{
baseCls : "x-plain",
style : "padding:5px",
layout : "column",
items : [{
columnWidth : .5,
layout : "form",
labelWidth : 55,
defaults : {
width : 160
},
baseCls : "x-plain",
defaultType : "textfield",
items : [{
layout : "form",
hideLabel : false,
fieldLable : "姓名"
}]
}, {
columnWidth : .5,
layout : "form",
labelWidth : 55,
baseCls : "x-plain",
items : {
xtype : "textfield",
fieldLable : "个人照片",
width : 170,
height : 177,
inputType : "image"
}
}]
}],
showLock : false,
listeners : {
"show" : function(_window) {
if (_window["showLock"]) {
_window.findByType("textfiled")[7].getEl().dom.src = "xxx.gif";
showLock = true;
}
}
}
});
_window.show();
});
本文详细介绍了如何利用Ext.js库实现Ajax请求,包括GET和POST方法的使用,以及不同数据格式(JSON、XML)的发送与接收。同时展示了如何创建动态窗口组件,涉及表单布局和字段配置。
1956

被折叠的 条评论
为什么被折叠?



