Ver Mensaje Individual
  #6 (permalink)  
Antiguo 19/04/2012, 12:44
kai89
 
Fecha de Ingreso: enero-2010
Mensajes: 373
Antigüedad: 15 años, 1 mes
Puntos: 5
Respuesta: crear variable

Si no quiero recargar la pagina, he buscado sobre ajax
y con este script muestra el resultado del input:

Cita:
<script language="javascript">
var http;
function getHTTP(){
var xmlhttp;
try
{
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e)
{
try
{
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e)
{
try
{
xmlhttp = new XMLHttpRequest();
}
catch(e)
{
xmlhttp= false;
}

}

}

return xmlhttp;

}
http=getHTTP();
function enviarDato(){
if(http){
var nombre=document.getElementById("nombre").value;
var codigo=document.getElementById("codigo").value;
http.open("GET","ej2.php?nombre="+nombre+"&codigo= "+codigo);
http.onreadystatechange = comunicacionPHP;
http.send(null);
}else
alert("No hay HTTP");
}
function comunicacionPHP(){
if(http.readyState == 4)
{
if(http.status == 200){
rspta = http.responseText;
//Aqui va la respuesta del servidor
alert(rspta);
}
}
}
</script>
y luego para ver el resultado del input :

Cita:
<?php
$txt = " ".$_GET["nombre"].";
echo $txt;
?>
El problema ske el resultado se muestra en una alerta, pero en el codigo php no hace nada,
¿como puedo hacer para que se muestre en el codigo php, y no en una alerta de javascript?