ajax在easyui中使用实例
发布时间:2020-12-16 00:40:01 所属栏目:百科 来源:网络整理
导读:td align="center" valign="middle" class="shimingrenz" a href="javascript:void(0);" style="text-decoration:none;color:#ffffff;" onClick="recognize()" 立即申请/a/td script type="text/javascript"function recognize(){ url = "recognizeUser"; va
<td align="center" valign="middle" class="shimingrenz" ><a href="javascript:void(0);" style="text-decoration:none;color:#ffffff;" onClick="recognize()" >立即申请</a></td> <script type="text/javascript"> function recognize(){ url = "recognizeUser"; var result = $.ajax({ url:url,dataType:"html",/* data:{userName : userName},*/ async:false,type:"get" }).responseText; Json = eval("(" + result + ")");//将字符串转为实际的对象 if(Json.user=="none") { window.open('https://localhost:8443/healthcloudpro/manager/subsystem/main/authShow.jsp'); } else if(Json.rows[1].value==null) { /* 没有通过验证且没有上传过信息 */ window.open('https://localhost:8443/healthcloudpro/manager/subsystem/main/Authentic.jsp'); } else window.open('/healthcloudpro/manager/subsystem/main/authRemind.jsp'); } </script> @Action(value = "/recognizeUser",results = { @Result(name = SUCCESS,location = "/manager/subsystem/main/sucess.jsp")}) public String reco() { HttpServletRequest request = ServletActionContext.getRequest(); HttpServletResponse response = ServletActionContext.getResponse(); HttpSession session = request.getSession(true); String s =(String) session.getAttribute("userid"); if(s==null) { String user="none"; String str = "{"user":""+user+""}"; PrintWriter out; try { out = response.getWriter(); out.println(str.toString());System.out.println("str"); out.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); return "fail"; } return SUCCESS; } int userid = Integer.parseInt(s); Userinfo userinfo = (Userinfo)userinfoService.findByUserid(userid); Map map = new HashMap(); ArrayList al = new ArrayList(); Map auth = new HashMap(); auth.put("name","isAuth"); auth.put("value",userinfo.getUserUuid()); Map idtype = new HashMap(); idtype.put("name","idtype"); idtype.put("value",userinfo.getIdtype()); Map authfail = new HashMap(); authfail.put("name","isAuthfail"); authfail.put("value",userinfo.getAuthenFail()); al.add(auth); al.add(idtype); al.add(authfail); map.put("total",1); map.put("rows",al); resultObj=JSONObject.fromObject(map); //将map对象转换成为json对象 System.out.println(resultObj); PrintWriter out; try { out = response.getWriter(); out.println(resultObj); out.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); return "fail"; } return SUCCESS; } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |