ajax练习,Ajax简单练习 - qqli的个人空间 - OSCHINA - 中文开源技术交流社区

Ajax

var xmlhttp;

var url = "test";

function loadXMLDoc(){

if(window.XMLHttpRequest){xmlhttp=new XMLHttpRequest();}

else{xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");}

if(xmlhttp != null){

xmlhttp.onreadystatechange=state_Change;

xmlhttp.open("GET",url,true);

xmlhttp.send(null);

}

else{alert("Your browser dose not support XMLHTTP.");}

}

function state_Change(){

if(xmlhttp.readyState==4 ){

if(xmlhttp.status==200){

document.getElementById("myDiv").innerHTML=xmlhttp.responseText;

}

else{

alert("Problem retrieving data:" +xmlhttp.statusText);

}

}

}

Let AJAX change this text