執行 ❯
建立您
自己的
網站
×
更改方向
儲存程式碼
更改主題,深色/淺色
轉到 Spaces
<!DOCTYPE html> <html> <body> <div id="demo"> <h2>The XMLHttpRequest Object</h2> <button type="button" onclick="loadDoc('ajax_info.txt', myFunction)">Change Content </button> </div> <script> function loadDoc(url, xFunction) { const xhttp=new XMLHttpRequest(); xhttp.onload = function() {xFunction(this);} xhttp.open("GET", url); xhttp.send(); } function myFunction(xhttp) { document.getElementById("demo").innerHTML = xhttp.responseText; } </script> </body> </html>