1. [代码] ajax script type="text/javascript"window.onload=function(){ var aNodes=document.getElementsByTagName("a"); for(var i=0;iaNodes.length;i++){ aNodes[i].onclick=function(){var request=new XMLHttpRequest();var method="GET";var url=t
1. [代码]ajax
<script type="text/javascript"> window.onload=function(){ var aNodes=document.getElementsByTagName("a"); for(var i=0;i<aNodes.length;i++){ aNodes[i].onclick=function(){ var request=new XMLHttpRequest(); var method="GET"; var url=this.href; request.open(method,url); request.send(null); request.onreadystatechange=function(){ if(request.readyState==4){ if(request.status==200){ document.getElementById("zqwang121").innerHTML=request.responseText; } } } return false; } } } </script>
2. [代码]html
<body> <h1>People</h1> <ul> <li><a href="1.html">1</a></li> <li><a href="2.html">2</a></li> <li><a href="3.html">3</a></li> </ul> <div id="zqwang121"></div> </body>