问题描述
- easyui form不提交后台
-
jsp<div id="addDlg" class="easyui-dialog" title="新增信息" data-options="minimizable:false" style="width:700px;height:300px;padding:10px;" closed="true"> <div class="easyui-layout" data-options="fit:true"> <div data-options="region:'center'" style="padding:10px"> <form id="addForm" method="post"> <table> <tr> <td align="right">创建人:</td> <td><input name="operater" id="oper" class="easyui-validatebox" required="true" value="${user.username}" readonly> <input type="hidden" name="id" id="opid" value="${user.id}"> <input type="hidden" name="orgId" id="orid"> </td> </tr> <tr> <td align="right">消息标题:</td> <td><input name="title" id="ti" class="easyui-validatebox" required="true" missingMessage="消息标题不能为空"> </td> </tr> <tr> <td align="right">正文:</td> <td> <textarea id="co" name="context" class="easyui-validatebox" required="true" missingMessage="消息标题不能为空" tyle="width:300px; border: 1px solid #ccc"></textarea> </td> </tr> </table> </form> </div> <div data-options="region:'east',split:true" style="width:200px;padding:10px"> <ul id="org" class="easyui-tree" data-options="url:'<%=root%>/getOrgInfo.do',method:'get',animate:true,checkbox:true"></ul> </div> <div data-options="region:'south',border:false" style="text-align:right;padding:5px 0 0;"> <a class="easyui-linkbutton" data-options="iconCls:'icon-ok'" href="#" onclick="javascript:add_ok()" style="width:80px">确定</a> <a class="easyui-linkbutton" data-options="iconCls:'icon-cancel'" href="#" onclick="javascript:$('#addDlg').window('close')" style="width:80px">取消</a> </div> </div> </div>
js
function add_ok() { var nodes = $('#org').tree('getChecked'); var s = ''; if(nodes.length == 0) { $.messager.alert('操作提示', '请选择机构'); return false; } $.messager.confirm('Confirm', '你确定要增加?', function(r) { if (r) { for(var i=0; i<nodes.length; i++){ if (s != '') s += ','; s += nodes[i].id; } $("#orid").val(s); $('#addForm').form('submit', { url:root + "/doSave.do", type : 'post', onSubimt:function() { var isvalid2 = $(this).form('validate'); if(isvalid2) { $.messager.alert('操作提示', '信息填写不完整!', 'error'); return false; } }, success : function() { $.messager.alert('操作提示', '添加信息成功!', 'info'); return true; } }); //$('#addForm').submit(); //实现Datagrid重新刷新效果 S('#tt').datagrid({ url : root + "/getInfoList.do" }); //关闭对话框 $('#addDlg').dialog('close'); } }); }
java
@RequestMapping("/doSave.do") @ResponseBody private Map<String, Object> doSave(@RequestParam InfoModel info) { log.info("保存新建信息开始"); Map<String, Object> modelMap = new HashMap<String, Object>(); modelMap.put("success", true); System.out.print(info); log.info("保存新建信息结束"); return modelMap; }
现在点击确定的时候不进后台对应的方法。
解决方案
firefox+firebug或者chrome开发工具看下报错了吗。。如root变量定义了没有
你的下面2句应该放到表单提交的回调里面吧。。要不上面的表单是ajax提交的都没有返回就执行下面2句了
S('#tt').datagrid({ url : root + "/getInfoList.do" });
$('#addDlg').dialog('close');
解决方案二:
http://www.haodaima.net/art/1567985
时间: 2024-12-28 19:41:33