Tema: Problem ajax
Ver Mensaje Individual
  #1 (permalink)  
Antiguo 15/12/2011, 07:44
MeRiNoxXx
 
Fecha de Ingreso: noviembre-2010
Mensajes: 5
Antigüedad: 13 años, 5 meses
Puntos: 0
Problem ajax

Hola gente. Soy nuevo en el uso de ajax y tengo un problemilla, no me entra al onreadystatechange.

Codigo:
function mostrar()
{
var x = document.getElementById("directorios");
var valor = x.value;
cargar("ajax.php?dir="+valor);
}
var conexion1;
function cargar(url)
{
conexion1 = crearXMLHttpRequest();
conexion1.open = ('GET',url,true);
conexion1.onreadystatechange =
function ()
{
var resultados = document.getElementById("texto1");
if(conexion1.readyState == 4)
{
resultados.innerHTML = "hola";
}
else
{
resultados.innerHTML = 'Accediendo...';
{
}
conexion1.send(null);
}

function crearXMLHttpRequest()
{
var xmlHttp = null;
if(window.ActiveXObject)
xmlHttp = new ActiveXobject("Microsoft.XMLHTTP");
else
if(window.XMLHttpRequest)
xmlHttp = new XMLHttpRequest();
return xmlHttp;
}
Pues en el div 'texto1' no llega nada.
He comprobado con alerts y dentro del onready no llega pero sin embargo justo antes de enviar la conexion si llega.
Alguna idea!!