源码:
<script type="text/javascript">
var xmlhttp;
function load(){
//注册xmlhttp
loadXMLDoc();
var url = "http://192.168.1.2:8180/tian/rs/Area";
xmlhttp.open("GET", url, true);
xmlhttp.onreadystatechange = loadDataCallBack;
xmlhttp.send(null);
}
function loadDataCallBack(){
if(xmlhttp.readyState==4){// 4 = "loaded"
if(xmlhttp.status==200){// 200 = "OK"
if (xmlhttp.responseText != ""){
document.write(xmlhttp.responseText);
}
}
}else{
alert("请求错误");
}
}
function loadXMLDoc(){
if(window.XMLHttpRequest){// code for Firefox, Opera, IE7, etc.
xmlhttp=new XMLHttpRequest();
}else if (window.ActiveXObject){// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
if(xmlhttp==null){
alert("Your browser does not support XMLHTTP.");
}
}
</script>
注册然后使用