﻿function ajaxObject(url, callbackFunction) {
   
   var that=this;
   this.updating = false; 
    
   this.abort = function() {
      if (that.updating) {
         that.updating=false;
         that.AJAX.abort();      
         that.AJAX=null;    
      }  
   }  
   
   this.send = function(passData,postMethod) {
      
      if (that.updating) { return false; }    
      that.AJAX = null;                              
      if (window.XMLHttpRequest) {
         that.AJAX=new XMLHttpRequest();                  
      } else {     
         that.AJAX=new ActiveXObject("Microsoft.XMLHTTP");    
      }
      
      if (that.AJAX==null) { 
         return false; 
      } else {
         that.AJAX.onreadystatechange = function() {
            if (that.AJAX.readyState==4) {
               that.updating=false;
               that.callback(that.AJAX.responseText,that.AJAX.status,that.AJAX.responseXML);
               that.AJAX=null;
            }
         }
         
         that.updating = true;
         
         var uri=urlCall;
         that.AJAX.open(postMethod, uri, true);
         that.AJAX.setRequestHeader('Content-Type','application/json; charset=UTF-8');
         that.AJAX.send(passData);
         
         return true;
      }
   }
   
   var urlCall = url;
   this.callback = callbackFunction || function () { };
}
