Skip to content

Instantly share code, notes, and snippets.

@7cc
Last active June 22, 2018 06:07
Show Gist options
  • Select an option

  • Save 7cc/7c8edad9aad59c1df50fcdd0826695d3 to your computer and use it in GitHub Desktop.

Select an option

Save 7cc/7c8edad9aad59c1df50fcdd0826695d3 to your computer and use it in GitHub Desktop.
xhr or fetch for document
var url = ""
fetch(url).then(function(res){
res.text().then(function(mytext){
var doc = document.implementation.createHTMLDocument("")
doc.body.insertAdjacentHTML = mytext
console.log(doc)
})
})
function get(url) {
var xhr = new XMLHttpRequest()
xhr.open("get", url)
xhr.onload = function(res) {
console.log(xhr)
}
//xhr.responseType = "document"
xhr.setRequestHeader("content-type", "application/x-www-form-urlencoded;charset=UTF-8");
xhr.withCredentials = true
xhr.send(null)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment