最简单的Ajax

 

< script type = " text/javascript " >
var  xmlHttp;

function  createXMLHttpRequest()
{
    
if(windows.ActiveXObject)
    
{
        xmlHttp 
= new ActiveXObject("Microsoft.XMLHTTP");
    }

    
else if(windows.XMLHttpRequest)
    
{
        xmlHttp 
= new XMLHttpRequest();
    }

}


function  startRequest()
{
    createXMLHttpRequest();
    xmlHttp.onreadystatechange
=handleStateChange;
    xmlHttp.open(
"GET","xxx.html",true);
    xmlHttp.send(
null);
}


function  hadnleStateChange()
{
    
if(xmlHttp.readyState==4)
    
{
        
if(xmlHttp.status==200)
        
{
            
//doSomething;
        }

    }

}

</ script >

你可能感兴趣的:(Ajax)