Ext js Ajax 基本用法
最近在做一个项目时候用到了使用Ext 进行异步的请求,对Ext.Ajax.request有了点基本的认识
基本结构如下:
Ext.Ajax.request({ url:'xxx.do', method : 'post',// 请求的方式 GET OR POST params : {id : id}, // 传递的参数 scope:this, // 修改函数的this对象// 成功时候的回调函数 success : function(response, options) { },// 失败时候的回调函数 failure : function(response, options) { }});
@Overrideprotected void doPost(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException{ JSONObject responseJSON = new JSONObject(); //.................... response.getWriter().write(responseJSON.toString());response.getWriter().flush();}
success : function(response, options){ var text = Ext.decode(response.responseText); // 通过text. 来获得对应的值if(text.success){}