当前位置: 代码迷 >> Ajax >> jQuery+Ajax+Struts1例证
  详细解决方案

jQuery+Ajax+Struts1例证

热度:338   发布时间:2012-12-26 14:39:29.0
jQuery+Ajax+Struts1例子
    public ActionForward validateLoginId(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
        String loginId = request.getParameter("login_id");
        String status = "1";
    	if(RmStringHelper.checkNotEmpty(loginId)){
    		List<RmCommonVo> resultList = null;
    		resultList=RmProjectHelper.getCommonServiceInstance().doQuery("select ID from RM_USER  where USABLE_STATUS='1' and LOGIN_ID='"+loginId+"'");
    		if(resultList.size()==0){
    			status = "0";
    		}
    	}
    	response.getWriter().print(status);
        return null;
    }

?

function validateLoginId(){
		var sValue = true;
		$.getJSON("<%=request.getContextPath()%>/RegisterUserAction.do?cmd=validateLoginId", 
			{
				login_id:$("#login_id").val()
			}, 
			function(data){
				if(data == '1') {
					//alert("登录账号重复!");
					writeValidateInfo("登录账号已被使用,请重新输入!",document.getElementById("login_id"));
					sValue = false;
				}else{
					writeValidateInfo("",document.getElementById("login_id"));
					sValue = true;
				}
			});
		return sValue;
	}
?
  相关解决方案