我尝试通过 ajax 访问我的控制器以获取数据库结果,但它不起作用。ajax 位于提交按钮内,并且在没有 ajax 的情况下也能很好地执行。该代码应该执行查询并检查输入是否存在。这是我的 ajaxvar jsonData = { "appname": appname, "txtype": txtype, "ipaddress": ipaddress }; $.ajax({ type: 'POST', url: "checkaccesspermission.html", data: jsonData, success: function(data) { if(data == "exists"){ alert('Permission Already Exists!'); return false; }else{ alert('Add Permission test Succesful!'); return true; } }, async: false });这是我的控制器 @RequestMapping(value="/checkaccesspermission", method=RequestMethod.GET) public String checkaccesspermission(@ModelAttribute("loginForm") IpAccessManagementModel loginForm, Model model, @RequestParam("ipaddress") String ipaddress, @RequestParam("txtypeHidden") String txtype, @RequestParam("appIDHidden") String appID) throws IOException{ System.out.println("CHECKACCESSPERMISSIONs"); IpAccessManagementModel sub = new IpAccessManagementModel(); //System.out.println("<script language='JavaScript'>alert('Hello');</script>"); sub.setAppName(appID); sub.setTxtType(txtype); sub.setIpAddress(ipaddress); System.out.println(ipaddress); ipAccessMGTDAO.addPermission(sub); String resultCheckExist = ipAccessMGTDAO.checkAccessPermission(sub); return resultCheckExist; }
添加回答
举报
0/150
提交
取消