function ajax(url,params,aonde,msg) {
  http.open("POST", url, true);
  http.onreadystatechange = function() { abrir(aonde,msg); };
  
  http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  http.setRequestHeader("Content-length", params.length);
  http.setRequestHeader("Connection", "close");

  http.send(params);
}

function abrir(aonde,msg) {
    ajx = document.getElementById(aonde);
  if (http.readyState == 1) { ajx.innerHTML = msg; }
  if (http.readyState == 4 && http.status == 200) { 
    res = http.responseText;
    ajx.value = res;
    ajx.innerHTML = res;
    ajx.innerHTML = res;
  }
}

function getXHTTP( ) {
  var xhttp;
   try {
      xhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        xhttp = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (e2) {
	    try {
	      xhttp = new XMLHttpRequest();
	    } catch (e3) {
	      xhttp = false;
	    }
      }
    }
  return xhttp;
}

var http = getXHTTP();