I have an ajax request that send vars by get on the url and gets xml nodes back. The ajax works good, in fact I can see the response when I debug with firebug... the problem is when I try to assign the number of nodes to a var by jquery.
this is the function:
function CargarTValores(){
try{
$.ajax({
url: 'f_func.php?f=g_tv&adm=1',
data: {},
success:function(result){
alert("entro");
var algo = 0;
algo = $(result).find('error').length;
if(algo>=1){
alert(toString($(result).find('error').first().text()));
}
},
error:function(){
alert("Error inesperado.");
}
});
}catch(e){
alert("algo paso");
}
}
I know that the response of the ajax is this:
<?xml version='1.0' encoding='utf-8'?><error>No existen Tipos de Valores en el sistema.</error>
so I know the length is at least 1 and if I put my mouse over the .length property on firebug it shows '1'.
by conclusion i think that my problem is on this line algo = $(result).find('error').length;
please tell what I'm doing wrong and thaks for your time ;)