如何通过Ajax技术解析HTML数据?

更新于
2026-09-29 08:17:36
2阅读来源:SEO问题
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计186个文字,预计阅读时间需要1分钟。

如何通过Ajax技术解析HTML数据?

1. [代码] AJAX 脚本javascriptwindow.onload=function() { var aNodes=document.getElementsByTagName(a); for (var i=0; i

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>

如何通过Ajax技术解析HTML数据?

本文共计186个文字,预计阅读时间需要1分钟。

如何通过Ajax技术解析HTML数据?

1. [代码] AJAX 脚本javascriptwindow.onload=function() { var aNodes=document.getElementsByTagName(a); for (var i=0; i

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>

如何通过Ajax技术解析HTML数据?