All pastes #960302 Raw Edit

Miscellany

public text v1 · immutable
#960302 ·published 2008-03-28 00:20 UTC
rendered paste body
// Class
function XMLRequest (url , sync) {

  // Setup
  this.method = "GET";
  this.url    = url;
  this.sync   = (typeof sync != undefined ? sync : true);

  // Stealable PUBLIC callback methods.
  this.onError    = function (e) {trace (e);}
  this.onLoad     = function (e) {trace (e);}
  this.onProgress = function (e) { percent.value = Math.ceil ((Number (e.position) / Number (e.totalSize)) * 100) + '%'; }
  this.onState    = function (e) {trace (e);}

  // Setup request and callbacks.
  // Private
  var __self = this;

  //Private
  var _conn = window.XMLHttpRequest != 'undefined' ? new XMLHttpRequest () : new ActiveXObject("Microsoft.XMLHTTP");

      _conn.onprogress    = function (e) { __self.onProgress (e); };
      _conn.onload        = function (e) { __self.onLoad (e, this.responseText); };
      _conn.onerror       = function (e) { __self.onError (e);    };
      _conn.onreadychange = function (e) { __self.onState (e);    };

      _conn.open (this.method, this.url, this.sync);


   //Public Send request.
   this.send = function () {

     _conn.send (null);
   }
}