<script> // Ajax let btn = document.getElementById("submit"); btn.onclick = function () { btn.onclick = function () { // 監控 xhr.onreadystatechange = function () { // 傳送成功且成功收到伺服器 if (xhr.readyState == 4 && xhr.status == 200) { 1 的json字串; / / let json = JSON.parse(xhr.responseText); // 寫入html中; // let tips = document.getElementById("ptips");回來"; } }; } }; let name = document.getElementById("username").value; let url = "check.php?name=" username "&password=" password; xhr.open("get", url, true); // 傳回瀏覽器 xhr.send(null));