Ajax.html:
Código:
Ajax.js:<script src="ajax.js" language="JavaScript"></script> Valor1: <input type=text id="texto1"><br> Valor2: <input type=text id="texto2"><br> <input type=button value="Enviar" onclick="sendGET();"> <div id=contenedor></div>
Código:
Ajax1.php:function crearXMLHttpRequest() {
var xmlHttp=null;
if (window.ActiveXObject) {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
} else {
if (window.XMLHttpRequest) {
xmlHttp = new XMLHttpRequest();
}
}
return xmlHttp;
}
var conexion1 = crearXMLHttpRequest();
function procesarEventos() {
var contenedor = document.getElementById("contenedor");
if (conexion1.readyState == 4) {
contenedor.innerHTML = conexion1.responseText;
} else {
contenedor.innerHTML = "Cargando...";
}
}
function sendGET() {
var t1, t2; // variables que contendran los valores de los campos a mandar
t1 = document.getElementById("texto1").value;
t2 = document.getElementById("texto2").value;
conexion1.open("GET", "ajax1.php?texto1="+t1+"&texto2="+t2, true);
conexion1.onreadystatechange = procesarEventos();
conexion1.send(null);
}
Código:
El problema es que cuando apreto el boton que esta en Ajax.html, el div "contenedor" pasa a tener el texto "Cargando...", lo cual esta bien, pero se queda ahi y nunca llega a tener el texto "Informacion recibida".<?php
if (isset($_GET["texto1"]) and isset($_GET["texto2"])) {
echo "Informacion recibida";
}
?>
Pareceria ser que la propiedad readyState del objeto conexion1 nunca llega a tener el valor 4.
Alguien puede ayudarme?
Saludos.

