//检查用户名是否注册 var isRegist = ""; $.ajax({ type: "POST",url: "registUsernameCheck.do",dataType : 'text',data : $('#form1').serialize(),async: false,success: function (data) { if (data == 1) { $("#usernametip").html(""); isRegist = ""; } else { $("#usernametip").html("<img src='<%=request.getContextPath()%>/images/error.png'/><font color='red'>该用户名已经被注册!</font>"); isRegist = "registed"; } } }); if(isRegist.length == 0){ }else{ return false; }
把异步处理设置 为false;即可给方法外部赋值:
<span style="color:#cc0000;"> async: false,</span>原文链接:https://www.f2er.com/ajax/164483.html