Ver Mensaje Individual
  #19 (permalink)  
Antiguo 17/01/2011, 11:08
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

hice lo que me dijiste Panino5001 y tampoco me suma los dos valores

<html>
<head>
<script type="text/javascript">
function loadXMLDoc()
{
a = document.getElementById("a").value;
b = document.getElementById("b").value;
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.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
}

</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>


y en demo_post.php


<?
$a=$_POST["a"];
$b=$_POST["b"];

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

?>