alanhe421 / coding-note

note
3 stars 1 forks source link

XMLHttpRequest #211

Open alanhe421 opened 4 years ago

alanhe421 commented 4 years ago
      var xhr = new XMLHttpRequest();
      xhr.open('get', '/hello1.json', true);
      xhr.onload = function (e) {
        console.log(xhr);
      };
      xhr.send();

经常使用的Axios实际上是对XHR做了二次封装

alanhe421 commented 4 years ago

异步

open方法的第三个参数支持同步异步设定。假如设定为false即同步,则send后面的逻辑会一直等着收到回复才可以继续执行。