search

ajax.js var http_request=false; function send_request(url){ url = url rand= new Date().valueOf(); http_request=false; //开始初始化XMLHttp对象 if(window.XMLHttpRequest){//MOILLA浏览器 http_request=new XMLHttpRequest(); if(http_request.overr

ajax.js

var http_request=false;

function send_request(url){
url = url + "&rand=" + new Date().valueOf();
http_request=false;
//开始初始化XMLHttp对象
if(window.XMLHttpRequest){//MOILLA浏览器
 
http_request=new XMLHttpRequest();
 
if(http_request.overrideMimeType){
http_request.overrideMimeType("text/xml");
}
 
}else if(window.ActiveXObject){//IE 浏览器
try{
http_request=new ActiveXObject("Msxml2.XMLHttp");
}catch(e){
try{
http_request=new ActiveXObject("Microsoft.XMLHttp");
}catch(e){
alert("浏览器不支持此方法,请更换浏览器!");
return false;
}
}
 
}
if(!http_request){
window.alert("创建XMLHttp对象失败");
return false;
}
 
http_request.onreadystatechange=processrequest;
//确定发送请求方式,URL,及是否同步执行下段代码
http_request.open("GET",url,true);
http_request.send(null);
 
}
//处理返回信息函数
function processrequest(){
if(http_request.readyState==4){
if(http_request.status==200){
document.getElementById(reobj).innerHTML=http_request.responseText;
}else{
alert("您所请求的页面不正常");
}
}
}
function do_ajax(obj,url){
document.getElementById(obj).innerHTML="查询中...";
send_request(url);
reobj=obj;

}

reg.html



ajax测试



假设已经注册过的用户名有tom,leo,lili,richard




用户名:




check.php



//链接数据库
$link = mysql_connect('localhost','root','123') or die('连接数据库失败,系统给的提示是:'.mysql_error());


//选择数据库
mysql_select_db('opp_blog') or die ('选择数据库失败,系统给的原因是:'.nysql_error());


$sql ="select * from opp_user";
//echo $sql;
$result = mysql_query($sql) or die(mysql_error());
//查询数据
#while($username=mysql_fetch_array($result)){
#echo "

";
#var_dump($username['username']);
#}
$usernames =mysql_fetch_array($result);






$names = array('tom','leo','lili','richard');
if($_GET['username']){
sleep(2);//这一句是为了展示查询过程值得变化,下面也是模拟查询过程,实际你可以到数据库查询
    if(in_array($_GET['username'],$usernames)){
        echo '此用户名已存在';
    }else{
        echo '恭喜,可以使用';
    }
}else{
    echo '请输入用户名';
}
?>





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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools