var request = new XMLHttpRequest();
request.open('GET', 'https://www.google.com', true);
request.onload = function() {
if (request.status >= 200 && request.status < 400) {
// Success!
var data = request.responseText;
} else {
// We reached our target server, but it returned an error
...