lo puse a si y no me sale
esta es la pagina a1.php
Código PHP:
Ver original<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title
>Documento
sin t
í
;tulo
</title
> <script type="text/javascript">
function requerir(){
try{
req=new XMLHttpRequest();
}catch(err1){
try{
req=new ActiveXObject("Microsoft.XMLHTTP");
}catch(err2){
try{
req=new ActiveXObject("Msxml2.XMLHTTP");
}catch(err3){
req= false;
}
}
}
return req;
}
var peticion=requerir();
function llamarAjax(){
var aleatorio=parseInt(Math.random()*999999999);
var campo=document.form1.apellido.value;
var campo2=document.form1.nombre.value;
var url="codigo.php?var="+campo+"&r="+aleatorio+"&c2="+campo2;
peticion.open("GET",url,true);
peticion.onreadystatechange =respuestaAjax;
peticion.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
peticion.send(null);
}
function respuestaAjax(){
if(peticion.readyState==4)
{
if(peticion.status==200)
{
//alert(peticion.responseText);
var dina = peticion.responseXML.getElementsByTagName("var")[0];
var apellidoDiv= peticion.responseXML.getElementsByTagName("c2")[0];
document.getElementById("dina").innerHTML=dina.childNodes[0].nodeValue;
document.getElementById("apellidoDiv").innerHTML=apellidoDiv.childNodes[0].nodeValue;
}
else
{
alert("ha ocurrido un error"+peticion.statusText);
}
}
else
{
document.getElementById("dina").innerHTML='<img src="carga.gif" />';
}
}
</script>
</head>
<body>
<div id="dina"></div>
<form action="" method="post" enctype="application/x-www-form-urlencoded" name="form1" id="form1">
<label>
<input type="text" name="nombre" id="nombre" />
<div id="dina"></div><!--aqui quiero traer de la pagina solo la variable $_GET['var']; -->
</label>
<label>
<input type="text" name="apellido" id="apellido" />
<div id="apellidoDiv"></div> <!--aqui quiero traer de la pagina solo la variable $_GET['c2'];-->
</label>
<input name="" type="button" onclick="llamarAjax()" />
</form>
</body>
</html>
y esta es la pagina codigo.php
Código HTML:
Ver original<?php
header('Content-Type: text/xml');
echo "<?xml version=\"1.0\"?><var>".$_GET['var']."
</var><c2>".$_GET['c2']."
</c2>";
?>
lo peor es que solo sale el gif animado por el error que tiene
como le puedo hacer