var AjaxPost = function(obj) {
  // setup pars for the class
  this.setup(obj);
}

AjaxPost.prototype = {
  setup: function(pars) {
    this.method = pars.method || "post";
    this.form = pars.form;
    this.action = pars.action;
    this.success = pars.success;
    this.loading = pars.loading;
  },
  
  send: function() {
    var THIS = this;
    var xmlHttp = new XMLHttpRequest();
    xmlHttp.open(this.method, this.action, true);
    xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xmlHttp.onreadystatechange = function() {
      if(xmlHttp.readyState == 4) {
        responseText = xmlHttp.responseText;
        THIS.success(responseText);
      } else {
        THIS.loading();
      }
    }
    xmlHttp.send($('#' + THIS.form).serialize());  
  }
}