Ver Mensaje Individual
  #1 (permalink)  
Antiguo 18/05/2017, 12:18
botarate
Usuario no validado
 
Fecha de Ingreso: junio-2012
Mensajes: 9
Antigüedad: 11 años, 10 meses
Puntos: 0
no me crea objeto ajax

estoy intentando crear un objeto ajax y lo hago con este codigo

Código:
function CrearAjax()
	{var ObjetoAjax=false; 
	var ObjetoAjax;
	if (window.XMLHttpRequest) 
	{ObjetoAjax = new XMLHttpRequest();
	}
	else if (window.ActiveXObject) 
	{ObjetoAjax= new ActiveXObject("Microsoft.XMLHTTP");
	}
	return ObjetoAjax;
	}

function CalculoIva()
{
var Ajax=CrearAjax();
	Ajax.onreadystatechange= function()
		{
			if (Ajax.readyState==4)
			{alert(Ajax.readyState);
				if (Ajax.status==200)
				{alert (Ajax.status);}
			else {alert ("Error");}
			}
			else{alert(Ajax.readyState);}
		}
Ajax.open("POST","pagina.php",true);
}
el resultado es que me lanza el alert con Ajax.readyState=1 y no entiendo que esta mal,ya he pfobado con chrome y iexplorer y el resultado es el mismo.