extjs 简单的ajax请求实例和后台返回格式

来源:互联网 发布:c 字符串数组拷贝 编辑:程序博客网 时间:2024/05/21 10:14
var _hdevName = '';Ext.Ajax.request({    url: '/THDev/loadControl',    method: 'post',    params: {hDevID: _hdevid},    success: function (response) {        var responseJson = Ext.util.JSON.decode(response.responseText);        _hdevName = responseJson.data.hdevname; },    failure: function () {        alert('硬件名称查询失败!');    }});var d = new Ext.util.DelayedTask(function () {    txtHDevName.setValue(_hdevName);});d.delay(500); //延时保证ajax请求已返回
@RequestMapping("/loadMapDoor")public void loadMapDoor(String doorCode, HttpServletResponse response, HttpSession session) {    Print print = new Print();    print.WriteJson(response, doorService.loadDoorInfo(doorCode));}后台返回对象,不需要data  
responseJson.hdevname如果返回json对象
Json json = new Json();
json.setData(
doorService.loadDoorInfo(doorCode)
);print.WriteJson(response, json);
使用data解析
 _hdevName = responseJson.data.hdevname;





0 0
原创粉丝点击