去评论
dz插件网

原生ajax代码

逝水年华
2022/03/04 14:20:12
[HTML]  
  1. <!DOCTYPE html><html>
  2. <body>
  3. <h1>XMLHttpRequest 对象</h1>
  4. <p id="demo">让 AJAX 更改这段文本。</p>
  5. <button type="button">更改内容</button>
  6. <script>
  7. function loadDoc() {
  8.   var xhttp = new XMLHttpRequest();
  9.   xhttp.open("GET", "/demo/js/ajax_info.txt", false);
  10.   xhttp.send();
  11.   document.getElementById("demo").innerHTML = xhttp.responseText;
  12. }
  13. </script>
  14. </body>
  15. </html>