It's really easy to write Object Oriented Javascript

javascript Code:
  1. function DoSomethingWithResult(result)
  2. {
  3.     // result = responseText
  4. }
  5.  
  6.  
  7. function Ajax
  8. {
  9.     this.GetXmlHttpRequest =
  10.     function()
  11.     {
  12.         // no browser compatibility
  13.         return new XMLHttpRequest();
  14.     }
  15.  
  16.  
  17.     this.Request =
  18.     function(url, callback)
  19.     {
  20.         var xmlHttp = this.GetXmlHttpRequest();
  21.  
  22.         xmlHttp.onreadystatechange =
  23.         function()
  24.         {
  25.             if(xmlHttp.readyState == 4)
  26.             {
  27.                 if(xmlHttp.status == 200)
  28.                 {
  29.                     // call your function!
  30.                     callback(xmlHttp.responseText);
  31.                 }
  32.             }
  33.         }
  34.  
  35.         xmlHttp.open("GET", url, true);
  36.         xmlHttp.send(null);
  37.     }
  38. }


Then the call is simple:

javascript Code:
  1. var ajax = new Ajax();
  2.  
  3. ajax.Request("page.php?param1=this&param2=that", DoSomethingWithResult);