Ver Mensaje Individual
  #14 (permalink)  
Antiguo 17/01/2011, 08:53
Montes28
 
Fecha de Ingreso: septiembre-2010
Mensajes: 1.853
Antigüedad: 13 años, 8 meses
Puntos: 6
Respuesta: envio de datos (6 datos )xmlhttp.open("GET","views/getuser.php?q="+str,tr

que estoy haciendo mal

tengo dos input y quiero enviarlos por post y que en un div me retorne el resultado

<html>
<head>
<script type="text/javascript">
function loadXMLDoc()
{
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("myDiv").innerHTML=xmlhttp .responseText;
}
}
xmlhttp.open("POST","demo_post.php",true);
xmlhttp.send('var1=a&var2=b');
}
</script>
</head>
<body>

<h2>AJAX</h2>
<form action="" method="POST">
<input name="a" type="text" id="a">
<input name="b" type="text" id="b">
<div id="myDiv"></div>
<button type="button" onClick="loadXMLDoc()">Request data</button>
<p>Click the button several times to see if the time changes, or if the file is cached.</p>
</form>
</body>
</html>


$a=$_POST["var1"];
$b=$_POST["var2"];

$suma=$a+$b;
echo $suma;

no sale nada que estoy haciendo mal? gracias por responderme