[ Index ]

PHP Cross Reference of Eventum

title

Body

[close]

/js/ -> httpclient.js (source)

   1  function HTTPClient() {};
   2  
   3  HTTPClient.prototype = {
   4      xmlhttp: null,
   5      callback: null,
   6      
   7      loadRemoteContent: function(url, callbackFunction) 
   8      {
   9          this.callback = function(self) {
  10              eval(callbackFunction + '(self.xmlhttp);');
  11          }
  12          
  13          var self = this;
  14          
  15          // branch for native XMLHttpRequest object
  16          if (window.XMLHttpRequest) {
  17              this.xmlhttp = new XMLHttpRequest();
  18              this.xmlhttp.onreadystatechange = function() {
  19                  self.processReqChange(self);
  20              }
  21              this.xmlhttp.open("GET", url, true);
  22              this.xmlhttp.send(null);
  23          // branch for IE/Windows ActiveX version
  24          } else if (window.ActiveXObject) {
  25              this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  26              if (this.xmlhttp) {
  27                  this.xmlhttp.onreadystatechange = function() {
  28                      self.processReqChange(self);
  29                  };
  30                  this.xmlhttp.open("GET", url, true);
  31                  this.xmlhttp.send();
  32              }
  33          }
  34      },
  35  
  36      processReqChange: function(self) 
  37      {
  38          // only if req shows "complete"
  39          if (this.xmlhttp.readyState == 4) {
  40              // only if "OK"
  41              if (this.xmlhttp.status == 200) {
  42                  // ...processing statements go here...
  43                  self.callback(self);
  44              } else {
  45                  alert("There was a problem retrieving the data:\n" + this.xmlhttp.statusText);
  46              }
  47          }
  48      }
  49  }


Generated: Wed Dec 19 21:21:33 2007 Cross-referenced by PHPXref 0.7