$.ajax({ url: "<%=request.getContextPath()%>/supp/deleteSupp", data : {supplierId:supplierId}, async: false, //请求是否异步,默认为异步,这也是ajax重要特性 type: "GET", //请求方式 success: function(data) { var rs = eval('('+data+')'); flag = rs.success; if(flag){ alert("删除成功!"); } } });
下面是后台java代码:
@RequestMapping("/deleteSupp") @ResponseBody public Result<String> deleteSupplier(HttpServletRequest request){ Result<String> rs = new Result<>(); String supplierId = request.getParameter("supplierId"); supplierService.deleteSupplierById(supplierId); rs.setSuccess(true); return rs; }