Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

GeorgeLOL

Ajax dando erro no IE

Recommended Posts

Não estou conseguindo executar uma função bem simples em AJAX. Funciona normalmente no FF mas não no IE. o código é o seguinte:

 

try {
	xmlhttp = new XMLHttpRequest();
} catch (e) {
	try {
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
		try {
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (e) {
			xmlhttp = false;
		}
	}
}

xmlhttp.onreadystatechange = function() {
	if (xmlhttp.readyState == 4) {
		alert(xmlhttp.responseText);
	}
}

xmlhttp.open("GET","engine.php?oie=aoaoaoa",true);
xmlhttp.send(null);

o engine.php apenas dá um echo no $_GET['oie'];

 

daí, no IE dá o seguinte erro:

 

Automation server can't create object.

isso dá na linha que tem a função xmlhttp.open;

 

o que pode ser isso? alguém pode me ajudar?

Compartilhar este post


Link para o post
Compartilhar em outros sites

Bom dia George Martins Gottardi:

 

Tenta deste jeito:

 

function iniAjax(){

var xmlhttp;

if(window.XMLHttpRequest){

xmlhttp = new XMLHttpResquest();

}else if(window.ActiveXObject){

xmlhttp = new ActiveXObject("Msxml.XMLHTTP");

if(!myAjax){

xmlhttp = new ActiveObject("Microsoft.XMLHTTP");

}

}

return myAjax;

}

function Blablabla(){

ajax = new iniAjax();

ajax.open("GET","engine.php?oie=aoaoaoa",true);

ajax.onreadystatechange = function() {

if (ajax.readyState == 4) {

if(ajax.status == 200){


alert(ajax.responseText);

}
}
}
ajax.send(null);

}
Testa ae e diz pra nós se funcionou.

 

beleza! Abraço a véi!!!

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.