//该文件为register.php,在客户端
用户注册
//创建ajax引擎
function getxmlhttpobject(){
var xmlhttprequest;
//不同浏览器获取对象xmlhttprequest对象方法不同
if(window.activexobject){
xmlhttprequest = new activexobject(microsoft.xmlhttp);
}else{
xmlhttprequest = new xmlhttprequest();
}
return xmlhttprequest;
}
/*
function getxmlhttpobject(){
//不同浏览器获取对象xmlhttprequest对象方法不同
var xmlhttp = null;
try{
//firefox, opera 8.0+, safari
xmlhttp = new xmlhttprequest();
}catch(e){
//internet explorer
try{
xmlhttp = new activexobject(msxml2.xmlhttp);
}catch(e){
xmlhttp = new activexobject(microsoft.xmlhttp);
}
}
return xmlhttp;
}
*/
var myxmlhttprequest = ;
//验证用户名是否存在
function checkname(){
//1号线
myxmlhttprequest = getxmlhttpobject();
//判断创建成功?
if(myxmlhttprequest){
//通过myxmlhttprequest对象发送请求到服务器的某个页面
//第一个参数表示请求的方式, get/post
//第二个参数指定url,对哪个页面发出ajax请求(本质仍然是http请求)
//第三个参数.true表示使用异步机制,false表示不使用异步机制
//注意:此处如果username和=之间有空格,否则会出错,在服务器端接收不到username;
//注意:如果=之后有空格则将此空格也作为接收到的username的值的一部分。
//即在服务器端收到的username的值=“ ”(即空格)+从客户端发送的username值。
var url = /ajaxtest/registerprocess.php?username= + $(username1id).value;
//window.alert(url);
//打开请求
myxmlhttprequest.open(get,url,true);
//指定回调函数.process是个函数名
myxmlhttprequest.onreadystatechange = process;
//真正发送请求。如果是get请求则填入null即可
//如果是post请求,则填入实际的数据
//2号线
myxmlhttprequest.send(null);
}
}
//回调函数
function process(){
//window.alert(这是回调函数 + myxmlhttprequest.readystate);
//我要取出从registerprocess.php页面返回的数据
if(myxmlhttprequest.readystate == 4){
//取出值,根据返回信息的格式而定
//window.alert(服务器返回 + myxmlhttprequest.responsetext);
//4号线
$('myresponse').value = myxmlhttprequest.responsetext;
}
}
function $(id){
return document.getelementbyid(id);
}
用户名:
密码:
电子邮件:
用户名:
密码:
电子邮件:
[php]
//该文件为registerprocess.php,在服务器端
http://www.bkjia.com/phpjc/477808.htmlwww.bkjia.comtruehttp://www.bkjia.com/phpjc/477808.htmltecharticle[php] //该文件为register.php,在客户端 html head title用户注册/title meta http-equiv = content-type content = text/html;charset=utf-8/ script type = text/javascript //创建...