xml - issue assigning ajax response length to a var by jquery -
this question has answer here:
- how return response asynchronous call? 21 answers
i have ajax request send vars on url , gets xml nodes back. ajax works good, in fact can see response when debug firebug... problem when try assign number of nodes var jquery.
this 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 response of ajax this: <?xml version='1.0' encoding='utf-8'?><error>no existen tipos de valores en el sistema.</error>
so know length @ least 1 , if put mouse on .length
property on firebug shows '1'.
by conclusion think problem on line algo = $(result).find('error').length;
please tell i'm doing wrong , thaks time ;)
pass datatype parameter in ajax call datatype: 'xml'
Comments
Post a Comment