日期:2014-05-17 浏览次数:20641 次
function saveUser(){ $('#addForm').form('submit',{ url: url, success: function(result){ alert(result); var result = eval('('+result+')'); alert(result); if (result.success){ $('#addDialog').dialog('close'); // close the dialog $('#test').datagrid('reload'); // reload the user data } else { $.messager.show({ title: 'Error', msg: result.message }); } } }); }
<action name="addRyxx" class="com.impms.action.RyxxAction" method="add"> <result name="success" type="json" > </result> </action>
public String add() { int flag = RyxxImpl.addRyxx(ryxx); if(flag==1){ //添加成功 success = true; message = "人员信息添加成功!"; }else{ //添加不成功 success = false; message = "人员信息添加不成功,请检查!"; } Map<String, Object> jsonMap = new HashMap<String, Object>();//定义map jsonMap.put("status", success); jsonMap.put("message", message); result = JSONObject.fromObject(jsonMap);//格式化result 一定要是JSONObject System.out.println(result); return SUCCESS; }