readyState of a document

Last Updated on December 1, 2015

The readyState of a document can be one of following:
Ripped from

The document is still loading. TCP handshake is in progress.

The document has finished loading and the document has been parsed but sub-resources such as images, stylesheets and frames are still loading. The state indicates that the DOMContentLoaded event has been fired.

The document and all sub-resources have finished loading. The state indicates that the load event has been fired. When the value of this property changes a readystatechange event fires on the document object.

Stack overflow on the readystate numbers

function Request(url, callback){
if (window.XMLHttpRequest) { // Mozilla, Safari, ...
    httpRequest = new XMLHttpRequest();
} else if (window.ActiveXObject) { // IE
    httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
} else{
        return false;

var readyStateChange = function(){

    if (httpRequest.readyState == 4) {

if (isFirefox && firefoxVersion > 3) {
    httpRequest.onload = readyStateChange;
} else {
    httpRequest.onreadystatechange = readyStateChange;

console.log(httpRequest, url);'GET', url, true);