有谁知道在不禁用异步的情况下使这个 ajax 函数工作的方法?Asynx=false 冻结一切......
<script type="text/javascript">
$(document).ready(function () {
$('#form5').bValidator();
});
function checkUsername(username){
var ret = false;
$.ajax({
type: 'POST',
url: 'checkuser.php',
sync: false, // Want to remove this
data: {'username':username},
success: function(data){
if(data == 'ok')
ret = true
}
});
return ret;
}
</script>
<form id="form5" method="post">
<p> Choose username:
<input type="text" data-bvalidator="checkUsername,required" data-bvalidator-msg="This username is not valid or already taken.">
</p>
<p>
<input type="submit" value="Submit">
<input type="reset" value="Reset">
</p>
</form>
http://karmela.fsb.hr/~bmauser/bvalidator/documentation.html#serversidevalidation