function ajax_request() {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == [READY_STATE] && this.status == [HTTP_RESPONSE_CODE]) {
// do something
}
};
xhttp.open("GET", [REQUEST_PATH], true);
xhttp.send();
}
Changes from 0 to 4:
0: request not initialized
1: server connection established
2: request received
3: processing request
4: request finished and response is ready
200: "OK"
404: "Page not found"