JQuery XML Parsing on error -


i'm trying parse xml in ajax response. when server returns 200 works fine. seems xml parsing in jquery disabled on error.

statuscode:{ 200:function(xml){alert($(xml).find("error").text());}, 404:function(xml){alert($(xml).find("error").text());} } 

if send 200 correct alert. if change response code whatever error like, empty alert box. plain stupid sending text/xml on error, bug in jquery or going wrong?

hope can help.

thanks

according jquery documentation,

if request successful, status code functions take same parameters success callback "success(data, textstatus, jqxhr)";

if results in error, take same parameters error callback "error(jqxhr, textstatus, errorthrown)"

that means in 404 callback "function(xml){alert($(xml).find("error").text());" 'xml' jqxhr object , understandably $(xml).find("error").text() nothing.

share|improve answer
    
thanks hint got solved: had use $(xml.responsexml).find("error") way response got transformed jquery object on perform find() thanks – javajens mar 8 '12 @ 11:08

your answer

 
discard

posting answer, agree privacy policy , terms of service.

not answer you're looking for? browse other questions tagged or ask own question.

Comments