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