mousepc 发表于 2013-1-29 10:48:49

一个ajax例子

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><script type="text/javascript">function loadXMLDoc(){var xmlhttp;if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safarixmlhttp=new XMLHttpRequest();}else{// code for IE6, IE5xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");}xmlhttp.onreadystatechange=function(){if (xmlhttp.readyState==4 && xmlhttp.status==200)    {    document.getElementById("myDiv").innerHTML=xmlhttp.responseText;    }}xmlhttp.open("GET","test.txt",true);xmlhttp.send();}</script></head><body><h2>AJAX</h2><button type="button" >请求数据</button><div id="myDiv"></div></body></html>
页: [1]
查看完整版本: 一个ajax例子