备注:XHR(XMLHttpRequest)
(建议使用axios。)
2.1. 优缺点
XHR
缺点:
API用法繁琐。
没有关注分离的设计思想。
fetch
优点:
关注分离的设计思想。...原生JS 实现 AJAX
直接使用XHR(XMLHttpRequest)。...var xhr = new XMLHttpRequest();
xhr.open("get",url, true);
xhr.send(null);
xhr.onreadystatechange = function...Content-Type' header
cache: 'no-cache', // *default, no-cache, reload, force-cache, only-if-cached
credentials...mode: 'cors', // no-cors, cors, *same-origin
redirect: 'follow', // manual, *follow, error
referrer