前端之家收集整理的这篇文章主要介绍了
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;
}
原文链接:https://www.f2er.com/ajax/165189.html