同步跟非同步

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <button onclick="doAjax();">doAjax</button>
    <button >test</button>
    <input type="text" name="testinput">
    <script>
        function doAjax(){
            const xhr = new XMLHttpRequest();
            xhr.onreadystatechange = function(event){
                console.log(xhr.status, xhr.readyState);
            }
            // xhr.open('GET','/ok', false);// 同步
            xhr.open('GET','/ok', true);// 非同步
            xhr.send();
        }
    </script>
</body>
</html>