XMLHttpResquest
var request = new XMLHttpRequest();
request.open('GET', url);
request.responseType = 'text'; # text, json
request.onload = function(){
para.textContent = request.response; // update content
}
request.send();
Fetch API
fetch(url).then(function(response){
response.text().then(function(text){
para.textContent = text; // update content
});
});
网友评论