if(isPass == true){
//发送注册异步请求
$.ajax({
type:"post",
url :"/user/register",
data:$("form").serialize(),
dataType:"json",
success:function(data){
alert(data);
if(data == "success"){
alert("注册成功");
window.location.href="/";//你跳转的页面
}else if(data == "fail"){
alert("注册失败:"+data);
}
},
error:function(){
//window.location.href="/111";
alert("注册异常");
return false;
}
});
alert("注册异常1");
return true;
}
执行代码后,为什么先是弹出注册异常1对话框,再弹出注册异常对话框呢
因为
ajax
是异步