Home  >  Article  >  Web Front-end  >  AJAX detect entered username without refreshing

AJAX detect entered username without refreshing

php中世界最好的语言
php中世界最好的语言Original
2018-03-31 15:09:451242browse

This time I will bring you AJAX to detect the entered user name without refreshing. What are the precautions for AJAX to detect the entered user name without refreshing? The following is a practical case. Let’s take a look. Let’s take a look at the schematic diagram first

register.php



 
  
  ajax无刷新检测
  
 
    

       
   发表留言    

                                                                                                      
留言标题:
网名:              
留言内容:
   
  

   

registerPro1.php

网名不可用";
// }else{
//  $info.="网名可用";
// }
// echo $info;
 //③
// $info="";
// if($username=="abc"){
//  //这里的$info返回的是一个字串
//  $info.='{"res":"不可用","id":"123","age":"5"}';
// }else{
//  $info.='{"res":"可用","id":"3","age":"1"}';
// }
// echo $info;
 //③+
 $info="";
 if($username=="abc"){
  //这里的$info返回的是一个字串
  $info.='[{"res":"不可用","id":"123","age":"5"},{"res":"abc不可用","id":"3","age":"0"}]';
 }else{
  $info.='[{"res":"可用","id":"1","age":"15"},{"res":"可用","id":"83","age":"9"}]';
 }
 echo $info;
?>

Rendering:

# I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website!

Recommended reading:

How to implement AJAX paging effect

Ajax to achieve infinite loading of lists and secondary drop-down menu options (attached Code)


How to use ajax to operate the form using JavaScript

The above is the detailed content of AJAX detect entered username without refreshing. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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