JSFiddle - React, Tailwind, and code Playground
by Darby Rathbone
JavaScript
function createCORSRequest(method, url) {
var xhr = new XMLHttpRequest();
if (xhr.hasOwnProperty(“withCredentials”)) {
xhr.open(method, url, true);
} else if (typeof XDomainRequest != “undefined”) {
xhr = new XDomainRequest();
xhr.open(method, url);
} else {
xhr = null;
}
return xhr;
};
var request = createCORSRequest(“get”, “http: //www.google.com");
if (request) {
request.onload = function () {
document.body.appendChild(document.createTextNode(request.responseText));
};
request.send();
}