从ext前端发送异步请求到 struts的Action后端,并获取后端的返回信息

来源:互联网 发布:西南期货软件 编辑:程序博客网 时间:2024/05/16 18:35

问题描述:

如何  从ext前端发送异步请求到 struts的Action后端,并获取后端的返回信息


解决方案:


1. Ext 前端.js文件中:
Ext.Ajax.request({   url: 'GoodAction_add.do'   ,method:'POST'   ,params: {// 发送的参数   sForm:sForm     ,dbHeight:dbHeight     ,sColor:sColor     ,sCraft:sCraft     ,dbWeight:dbWeight     ,dbWidth:dbWidth     ,sTypeNum:sTypeNum   }  ,scope: this   ,success: function(response,action){   var oResponse = Ext.util.JSON.decode(response.responseText);//这里是将后端outPrint()发出的json串转为对象。    alert("success !" + oResponse.msg );   }   ,failure:function(){   var oResponse = Ext.util.JSON.decode(response.responseText);    alert("failure !" + oResponse.msg );   }});


2. Action中:
String msg = "操作成功!";super.outPrint("{success:true,msg:\"" + msg + "\"}"); return "success";



原创粉丝点击