【发布时间】:2018-01-12 16:55:28
【问题描述】:
XHR 的 responseType='document' 非常棒,因为它会将一个 DOM 文档交还给您,您可以在其中使用 querySelector 等:
var xhr = new XMLHttpRequest();
xhr.open('GET', '/', true);
xhr.responseType = 'document';
xhr.onload = function(e) {
var document = e.target.response;
var h2headings = document.querySelectorAll('h2');
// ...
};
fetch 方法可以做到这一点吗?
【问题讨论】: