Wednesday, 28 August 2013

xml parse error ajax request

xml parse error ajax request

I'll go to straight to the point.
I have this ajax request on a function:
$.ajax({
url: 'f_func.php?f=g_tv&adm=1',
dataType: 'xml',
data: {},
async:false,
success:function(result){
if($(result).find('error').length>0){
alert($(result).find('error').first().text());
}else{
if ($(result).find('tvalor').length >0 ) {
$(result).find('tvalor').each(
function(i){
alert($(result).find(idtvalor).first().text());
}
);
}
}
},
error:function(XMLHttpRequest, textStatus, errorThrown){
alert(errorThrown);
}
});
the output is:
<?xml version='1.0' encoding='utf-8'?>
<tvalores>
<tvalor>
<idtvalor>1</idtvalor>
<nombtvalor>valag1</nombtvalor>
<puntaje>259</puntaje>
<estado>1</estado>
</tvalor>
<tvalor>
<idtvalor>2</idtvalor>
<nombtvalor>valag2</nombtvalor>
<puntaje>500</puntaje>
<estado>1</estado>
</tvalor>
</tvalores>
the error says it's a parsing xml error and I've been reading other topics
but they changed to JSon or the dataType from xml to text and eliminate
the header of the xml... I'm looking for a real fix on this...
if anyone can help me with this... thank you so much

No comments:

Post a Comment