W3School TIY Editor
W3School 在线教程
改变方向
暗黑模式
运行代码
<html> <head> <script type="text/javascript"> var xmlhttp; function loadXMLDoc(url) { xmlhttp=null; if (window.XMLHttpRequest) {// code for IE7, Firefox, Opera, etc. xmlhttp=new XMLHttpRequest(); } else if (window.ActiveXObject) {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } if (xmlhttp!=null) { xmlhttp.open("GET",url,false); xmlhttp.send(null); document.getElementById('A1').innerHTML=xmlhttp.status; document.getElementById('A2').innerHTML=xmlhttp.statusText; document.getElementById('A3').innerHTML=xmlhttp.responseText; } else { alert("Your browser does not support XMLHTTP."); } } </script> </head> <body> <h2>Using the HttpRequest Object</h2> <p><b>Status:</b> <span id="A1"></span> </p> <p><b>Status text:</b> <span id="A2"></span> </p> <p><b>Response:</b> <br /><span id="A3"></span> </p> <button onclick="loadXMLDoc('/example/xdom/note.xml')">Get XML</button> </body> </html>