JQuery ajax verify username exists

巴扎黑
Release: 2023-03-02 18:06:01
Original
1152 people have browsed it

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:

用户名:
Copy after login
$('#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+""); }); } });
Copy after login
 0){ echo "已存在"; exit; } else{ echo "可以注册"; exit; } ?>
Copy after login


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!