const xhr = new XMLHttpRequest();
xhr.open("GET", "/server", true);
// If specified, responseType must be empty string or "text"
xhr.responseType = "text";
xhr.onload = () => {
if (xhr.readyState === xhr.DONE) {
if (xhr.status === 200) {
console.log(xhr.response);
console.log(xhr.responseText);
}
}
};
xhr.send(null);XMLHttpRequest: responseText property / notebook
XMLHttpRequest: responseText property
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.