lib/loaders/LoaderBase.js
function () {
    if (this.xhr.readyState > 1) {
      var status;
      var waiting = false;
      // Fix error in IE8 where status isn't available until readyState=4
      try { status = this.xhr.status; } catch (e) { waiting = true; }

      if (status === 200) {
        switch (this.xhr.readyState) {

          // send() has been called, and headers and status are available
          case 2:

            this.fileMeta = new FileMeta(this.xhr.getAllResponseHeaders());

            this._dispatchStart();
            break;

          // Downloading; responseText holds partial data.
          case 3:

            // todo progress could be calculated here if onprogress does not exist on XHR
            // this.onProgress.dispatch();
            break;

          // Done
          case 4:

            this._parseContent();

            this._dispatchComplete();
            break;
        }
      } else if (!waiting) {
        this.xhr.onreadystatechange = undefined;
        this._dispatchError(this.xhr.status);
      }
    }
  }
function () {
    if (this.xhr.readyState > 1) {
      var status;
      var waiting = false;
      // Fix error in IE8 where status isn't available until readyState=4
      try { status = this.xhr.status; } catch (e) { waiting = true; }

      if (status === 200) {
        switch (this.xhr.readyState) {

          // send() has been called, and headers and status are available
          case 2:

            this.fileMeta = new FileMeta(this.xhr.getAllResponseHeaders());

            this._dispatchStart();
            break;

          // Downloading; responseText holds partial data.
          case 3:

            // todo progress could be calculated here if onprogress does not exist on XHR
            // this.onProgress.dispatch();
            break;

          // Done
          case 4:

            this._parseContent();

            this._dispatchComplete();
            break;
        }
      } else if (!waiting) {
        this.xhr.onreadystatechange = undefined;
        this._dispatchError(this.xhr.status);
      }
    }
  }
function ( ) { if ( this . xhr . readyState > 1 ) { var status ; var waiting = false ; // Fix error in IE8 where status isn't available until readyState=4 try { status = this . xhr . status ; } catch ( e ) { waiting = true ; } if ( status === 200 ) { switch ( this . xhr . readyState ) { // send() has been called, and headers and status are available case 2 : this . fileMeta = new FileMeta ( this . xhr . getAllResponseHeaders ( ) ) ; this . _dispatchStart ( ) ; break ; // Downloading; responseText holds partial data. case 3 : // todo progress could be calculated here if onprogress does not exist on XHR // this.onProgress.dispatch(); break ; // Done case 4 : this . _parseContent ( ) ; this . _dispatchComplete ( ) ; break ; } } else if ( ! waiting ) { this . xhr . onreadystatechange = undefined ; this . _dispatchError ( this . xhr . status ) ; } } }
This function is called whenever the readyState of the XHR object changes.

this.xhr.readyState == 2 //send() has been called, and headers and status are available
this.xhr.readyState == 3 //Downloading; responseText holds partial data.
this.xhr.readyState == 4 //Done

You should also handle HTTP error status codes:

this.xhr.status == 404 //file doesn't exist

@method _onStateChange
@protected
This function is called whenever the readyState of the XHR object changes .