title: How to make an AJAX call with pure javascript?
body: <p>I am new to Ajax and Javascript so i need this example  to be converted into ajax using pure javascript.How I can call this javascript as ajax and its functionality.need method like Common.prototype.ajax = function(method, url, data, callback) {};
  Common.prototype.ajaxGet = function(url, callback) {};
  Common.prototype.ajaxPost = function(url, data, callback) {};</p>
  
  <pre><code>    function Common() {
          console.log("Common Contructor fires!");
      }
  
      Common.prototype.setEvent = function(evt, element, callback) {
          var obj_idfier = element.charAt(0);
          var elementName = element.split(obj_idfier)[1];
          if (obj_idfier == '#') {
              var _ele = document.getElementById(elementName);
              _ele.addEventListener(evt, callback, false);
          } else if (obj_idfier == '.') {
              var _els = document.getElementsByClassName(elementName);
              for (var i=0; i&lt;_els.length; i++) {
                  _els[i].addEventListener(evt, callback, false);
              }
          } else {
              console.log("Undefined element");
              return false;
          }
          return this;
      };
  
      Common.prototype.getInnerHtml = function(id){
         return document.getElementById(id).innerHTML;
      };
  
      Common.prototype.setInnerHtml = function(ele, val){
         ele.innerHTML = val;
      };
  
      Common.prototype.getVal = function(ele){
         return ele.value;
      };
  
      Common.prototype.setVal = function(ele, val){
         ele.value = val;
      };
  
  
   function Calculator() {
  console.log("Calculater Constructor");
  }
  
  
  Calculator.prototype = new Common;
  
  Calculator.prototype.init = function() {
    var _this = this;
    var _ele = document.getElementById("math");
    var _numEle = document.getElementById("number");
  
        this.setEvent("click", ".control", function() { 
            console.log(this.value);
            var _num = _this.getInnerHtml('math');
            _num = _num + "" + _this.getVal(this);
            _this.setInnerHtml(_ele, _num);
        });
  
        this.setEvent("click", ".input", function() { 
            console.log(this.value);
            var _num = _this.getInnerHtml('math');
            _num = _num + "" + _this.getVal(this);
            _this.setInnerHtml(_ele, _num);
        });
  
        this.setEvent("click", ".clear", function() { 
            console.log(this.value);
            _this.setInnerHtml(_ele, "");
            _this.setInnerHtml(_numEle, "");
        });
  
        this.setEvent("click", ".submit", function() { 
            console.log(this.value);
        var _num = _this.getInnerHtml('math');
            _num = eval(_num+""+ _this.getVal(this));
            _this.setInnerHtml(_numEle, _num);
        });       
  
        };
        var calcObj = new Calculator();
       calcObj.init();
  </code></pre>