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
