function SendPOST()
{
var data = 'test'.value;
ajaxSendPOST('ajax.php','q='+encodeURI(data), SendCallback);
}

function SendCallback(answer) 
{ 
  var ans = eval( '(' + answer + ')' ); 
  if (ans.res=='error') { alert(ans.msg);return; } 
  if (ans.res!='ok') { alert('???');return; } 
  document.getElementById('x1').innerHTML=ans.x1; 

  
} 

function ajaxSendPOST(xmlpage,data,callback)
{ 
var xmlh = null;
if(window.XMLHttpRequest)
xmlh = new XMLHttpRequest();
else
try
{ xmlh = new ActiveXObject('Msxml2.XMLHTTP'); }
catch(ex) { xmlh = new ActiveXObject('Microsoft.XMLHTTP'); }
if(xmlh)
{
xmlh.open('post', xmlpage, true);
xmlh.onreadystatechange = function(x) { if(xmlh.readyState==4) callback(xmlh.responseText); }
xmlh.setRequestHeader("Accept-Charset", "utf8");
xmlh.setRequestHeader("Accept-Language","ru, en");
xmlh.setRequestHeader("Connection", "close"); 
xmlh.setRequestHeader("Content-length", data.length);
xmlh.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlh.send(data); 
}
}

