标签:http java 文件 数据 os javascript
注意url为网络路径
<html>
<head>
<script type="text/javascript"> 
 function loadXMLDoc(){  
  var xmlhttp;
  if(window.XMLHttpRequest){      
   xmlhttp=new XMLHttpRequest();   
  }else{
   xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  } 
  xmlhttp.onreadystatechange=function(){
    if(xmlhttp.readyState==4 && xmlhttp.status==200){ 
    var tempStr=xmlhttp.responseText;
    alert(tempStr);
    var people=eval(‘(‘+tempStr+‘)‘);
    alert(people.authors[0].lastName);
  }
    
   }
   xmlhttp.open("GET","http://www.cngef.org.cn/a.txt",false);
  xmlhttp.send();
}
   </script>
</head>
   <body>
    <h2>AJAX</h2>
    <button type="button" onclick="loadXMLDoc()">请求数据</button><div id="myDiv"></div>
   </body>
</html>
标签:http java 文件 数据 os javascript
原文地址:http://www.cnblogs.com/qiyongliang/p/3818421.html