function doCheck(roomId,userEname,status,i){ $.post("${ctx}/admin/user/docheck",{roomId:roomId,userEname:userEname,status:status,i:i},function(data){ var oTxt=jQuery.parseJSON(data); alert(oTxt.msg); if(oTxt.flag=="T") $("#check"+i).hide(); }); }
后台JAVA:
public @ResponseBody String approveUser(HttpServletRequest request,HttpServletResponse response,@RequestParam(value="id") String id,@RequestParam(value="roomId") String roomId){ JSONObject json=new JSONObject(); try{ roomUserManager.modfiy(id,roomId); json.put("flag","T"); json.put("msg","审核通过"); }catch(Exception ex){ json.put("flag","F"); json.put("msg","操作异常"); } showJson(json,response); }
protected String showJson(JSONObject jvo,HttpServletResponse response){ try { response.setContentType("text/html;charset=UTF-8"); PrintWriter out = response.getWriter(); out.print(jvo.toString()); } catch (Exception e) { e.printstacktrace(); } return null; }