ajax在easyui中使用实例

<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
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值