The ajax's key technology is the XmlHttpRequest.and there is the ajax application frame.
javascript file:
var xmlHttp;
function createXMLHttpRequest() {//create the XmlHttpRequest object
if(window.XMLHttpRequest){
xmlHttp=new XMLHttpRequest();
}
if(window.ActiveXObject){
try{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e){}
try{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e){}
if(!xmlHttp){
alert("can't create XMLHttpRequest instance!");
return false;}
}
}
function CallBackFunction(){// callback
if(xmlHttp.readyState==4){
if(xmlHttp.status==200){
if(xmlHttp.responseText=="true"){
//some operate
} else{
//some operate
}
}
}
function ClientCallFunction(userName){//client call
createXMLHttpRequest();
var url="OperateData.aspx?UserName="+userName;
xmlHttp.open("GET",url,true);
xmlHttp.onreadystatechange=CallBackFunction;
xmlHttp.send(null);
}
javascript file:
var xmlHttp;
function createXMLHttpRequest() {//create the XmlHttpRequest object
if(window.XMLHttpRequest){
xmlHttp=new XMLHttpRequest();
}
if(window.ActiveXObject){
try{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e){}
try{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e){}
if(!xmlHttp){
alert("can't create XMLHttpRequest instance!");
return false;}
}
}
function CallBackFunction(){// callback
if(xmlHttp.readyState==4){
if(xmlHttp.status==200){
if(xmlHttp.responseText=="true"){
//some operate
} else{
//some operate
}
}
}
function ClientCallFunction(userName){//client call
createXMLHttpRequest();
var url="OperateData.aspx?UserName="+userName;
xmlHttp.open("GET",url,true);
xmlHttp.onreadystatechange=CallBackFunction;
xmlHttp.send(null);
}