Actually, there are many examples of this on the Internet, but when I was doing it, I ran into some problems, and finally found a solution to the problem, so I wanted to post it and record it as a warning.
The code is as follows:
$('#cname').blur(function(){ if($('#uname').val() == ''){ $('#result').html("不能为空"); } else{ //var str = 'cname='+$('#cname').val(); $.get('test.php',{username:$('#uname').val()},function(data){ $('#result').html(""+data+""); }); } });
0){ echo "已存在"; exit; } else{ echo "可以注册"; exit; } ?>