HTML and CSS Reference
In-Depth Information
var container = document.querySelector("#container");
if (this.status === 200) {
var domParser = new DOMParser(),
externalDocument = domParser.parseFromString(this.responseText,
'text/html'),
card = externalDocument.querySelector("#card").outerHTML;
setCardContent(card);
bindLinks();
} else {
setCardContent('<div id="card"><h1>Oops</h1><p>Something went
wrong!</p></div>');
}
}
}
xhr.send();
}
The first line in this function instantiates a new XMLHttpRequest ( xhr ) object. The
second line sets up the xhr request. The open method accepts the following five
parameters:
Method-----GET, POST
URL
Async-----true, false (defaults to true and will continue to run
JavaScript after the send method is called. If set to false, it will
freeze the browser until the request is complete after running
the send method)
User (if the request is protected by an HTTP username and
password, you can enter the username here)
Password (if the request is protected by an HTTP username
and password, you can enter the password here)
Calling open does not make the Ajax request. The fourth line sets the handler for
the onreadystatechange event.
 
Search WWH ::




Custom Search