1. const xhr = new XMLHttpRequest();
    2. xhr.responseType = 'json';
    3. xhr.onreadystatechange = () => {
    4. if(xhr.readyState === 4) {
    5. if(xhr.status >= 200 && xhr.status < 300) {
    6. console.log('success', xhr.response);
    7. }
    8. }
    9. }
    10. // true 是否异步
    11. xhr.open('GET', './user.json', true);
    12. xhr.send(null);