Home > Backend Development > PHP Tutorial > Detailed explanation of PHP+Ajax username detection_PHP tutorial

Detailed explanation of PHP+Ajax username detection_PHP tutorial

WBOY
Release: 2016-07-14 10:09:20
Original
870 people have browsed it

This example requires a total of 3 files

Detailed explanation of PHP+Ajax username detection_PHP tutorial
Ajax.js
var xmlHttp;
//Instantiation process
function S_xmlhttprequest(){
if(window.ActiveXObject){
xmlHttp=new ActiveXObject('Microsoft.XMLHTTP');
}else if(window.XMLHttpRequest){
xmlHttp=new XMLHttpRequest();
}
}
function funphp100(name){
//Get form content
//http://www.ruoshuiyx.com Shenyang website construction
var f=document.myform.user.value;
//Reference instantiation process
S_xmlhttprequest();
//Open request
xmlHttp.open("GET","index.php?id="+f,true);
//Ready to execute
xmlHttp.onreadystatechange=byphp;
xmlHttp.send(null);
}
function byphp() {
if(xmlHttp.readyState== 1) {
document.getElementById('php100').innerHTML = "";
}
if(xmlHttp.readyState== 4){
if(xmlHttp.status == 200) {
var byphp100 = xmlHttp.responseText;
document.getElementById('php100').innerHTML = byphp100;
}
}
}
For.php
Username//http://www.ruoshuiyx.com Shenyang website construction:
Index.php
if($id=$_REQUEST[id])
{
//for ($i=1;$i<3;$i++)
//{
// echo$id;
// sleep(1);//
//}
sleep(2);
if($id=='4125')
{
echo "already exists";
}
else
{
echo "Can register";
}
//exit();
}
?>
Knowledge points:
1. Principle of user name checking implemented by Ajax technology
Detailed explanation of PHP+Ajax username detection_PHP tutorial
2. Several triggers for learning HTML
The onblur event occurs when an object loses focus.
The onchange event occurs when the content of the field changes.
The onclick event occurs when the object is clicked.
The onfocus event occurs when an object gains focus.
The onkeydown event occurs when the user presses a keyboard key.
The onkeypress event occurs when a keyboard key is pressed and a key is released.
The onkeyup event occurs when a keyboard key is released.
The onmousedown event occurs when the mouse button is pressed.
The onmousemove event occurs when the mouse pointer moves.
The onmouseout event occurs when the mouse pointer moves out of the specified object.
The onmouseup event occurs when the mouse button is released.
3. How to get the data content in the form
document.myform.user.value

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/477696.htmlTechArticleThis example requires a total of 3 files Ajax.js var xmlHttp; //instantiation process function S_xmlhttprequest(){ if (window.ActiveXObject){ xmlHttp=new ActiveXObject(Microsoft.XMLHTTP); }else if(window...
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template