Essa parte é a única que você precisa entender, lol. Você endenteu? Ola, estou com o mesmo problema só que ao invés de usar xmlhttp.onreadystatechange = null; estava usando xmlHttp.onreadystatechange=stateChangedC;
function stateChangedC(){
if(xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
document.getElementById("exibeCidade").innerHTML=xmlHttp.responseText
}
}
trocando ele trava. É um script para buscar o nome das cidades referente ao estado que for selecionado. Consegui fazer com que ele funcione em todos os navegadores, mas esta faltando algo pois somente no IE ele pega o valor da cidade selecionado nos outros navegadores ele não pega o valor da cidade.
Se puderemos me ajudar, não consigo. Desde já, abradeço.
try{
xmlhttp = new XMLHttpRequest();
}
catch(ee){
try{
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e){
try{
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
catch(E){
xmlhttp = false;
}
}
}
if (navigator.userAgent.indexOf("Firefox") != -1) {
xmlHttp=GetXmlHttpObject();
}
if (navigator.userAgent.indexOf("MSIE") != -1) {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
if (navigator.userAgent.indexOf("Chrome") != -1) {
xmlHttp=GetXmlHttpObject();
}
if (xmlHttp==null){
alert ("Este browser não suporta HTTP Request")
return
}
document.getElementById("exibeCidade").innerHTML='Carregando as cidades...'
var url="php/selecionaCidade.php"
url=url+"?uf="+str
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=stateChangedC
xmlHttp.open("GET",url)
xmlHttp.send(null)
}
function stateChangedC(){
if(xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
document.getElementById("exibeCidade").innerHTML=xmlHttp.responseText
}
}