ajax在easyui中使用实例

来源:互联网 发布:淘宝可以不提供发票吗 编辑:程序博客网 时间:2024/06/05 16:58

<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;    }






0 0
原创粉丝点击