js code block
// ajax form submission function _tosubmit() { var value1 = $("input:radio[name='status']:checked").val(); var objid = $("#objid").val(); //alert(value1 + ";" + objid); $.ajax({ type : "POST", // method type dataType : "json", url : "${basePath}/manage/repair/UpdateStatus.shtml", // request path data : { "id" : objid, "status" : value1 }, callback:function(data){ } }); }body content
<body> <form id="form1" action="##" method="post"> <div class="pd-20"> <input type="hidden" name="id" id="objid" value="${obj.id }" /> <div class="row cl"> <label class="form-label1 col-3"><span class="c-red">*</span> Change status: </label> <div class="formControls col-3"> 未接收:<input type="radio" class="input-text" value="1" name="status" <c:if test="${obj.status==1}" >checked="checked" </c:if> /> 已接收:<input type="radio" class="input-text" value="2" name="status" <c:if test="${obj.status==2}" >checked="checked" </c:if> /> 已处理:<input type="radio" class="input-text" value="3" name="status" <c:if test="${obj.status==3}" >checked="checked" </c:if> /> </div> <div class="col-3"></div> </div> <div class="row cl"> <div class="col-9 col-offset-3"> <input type="button" onclick="_tosubmit()" class="btn btn-primary radius" id="btn" value=" submit "> <button type="button" id="delFun" onclick="closeWin()" class="btn btn-danger marR10">取消</button> </div> </div> </div> </form> </body>
In the common method, the type of the clicked login button is "submit";
In the common way, the action of the form is not empty;What should be paid attention to in the ajax method is the parameters in the $.ajax method: dataType and data.
background controller
@RequestMapping("UpdateStatus") @ResponseBody public String updatestatus(Integer id,Integer status) throws Exception{ Map<String,Object> map = new HashMap<String,Object>(); map.put("id", id); map.put("status", status); commonService.update("updateRepairStatus", map); return "ok"; }