Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Olá Galera, primeiramente Boa noite!
Tenho uma requisitação básica em AJAX.
vejam só:
function Ajax(pg,method,args,argsurl,p1,p2,p3)
{
var ret="";
try
{
ajax = new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e)
{
try {
ajax = new ActiveXObject("Msxml2.XMLHTTP");
}
catch(ex)
{
try {
ajax = new XMLHttpRequest();
}
catch(exc)
{
alert("Esse browser não suporta Ajax");
ajax = null;
}
}
}
if (!ajax)
{
//Nao conseguiu instanciar o objeto xmlhttp para fazer as solicitacoes
alert("AJAX error. Your browser must support XMLHttpRequest object or enable use of scripting.");
}
if(ajax != null)
{
ajax.open(method,pg + argsurl,false);
ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=iso-8859-1");
ajax.setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate");
ajax.setRequestHeader("Cache-Control", "post-check=0, pre-check=0");
ajax.setRequestHeader("Pragma", "no-cache");
ajax.onreadystatechange = status;
ajax.send(args);
}
function status()
{
if (ajax.readyState == 4)
{
if(ajax.status == 200)
{
ret = returnValue(ajax.responseXML);
}
else
{
window.alert('problemas');
}
}
}
function returnValue(response)
{
return response;
}
return ret;
}
Visto que é uma requisitação comum.
Mas o problema vem aqui
function getDest(c)
{
var dest = Ajax("getdest.asp","POST","cd=" + c,"");
/* -->>> O Erro está aqui! <<<-- */ document.getElementById("destblock").getElementsByTagName("div")[0].getElementsByTagName("strong")[0].innerHTML = dest.getElementsByTagName("titulo")[0].childNodes[0].nodeValue;
document.getElementById("destblock").getElementsByTagName("div")[0].getElementsByTagName("p")[0].innerHTML = dest.getElementsByTagName("conteudo")[0].childNodes[0].nodeValue;
document.getElementById("destblock").getElementsByTagName("div")[0].getElementsByTagName("span")[0].innerHTML = dest.getElementsByTagName("links")[0].childNodes[0].nodeValue;
}
Na função acima eu só quero pegar cada pedaço do xml e colocar em um devido local do html e isso funciona no IE, mas no Firefox diz:
Erro: dest.getElementsByTagName is not a function
Arquivo-fonte: http://10.1.1.3/cecilia/web/webcis/js/jscript.js
Linha: 67
Ele não reconhece a função dest.getElementsByTagName("titulo")[0].childNodes[0].nodeValue;
Alguém pode me ajudar a contornar a situação? Obrigado!
Carregando comentários...