var fData = getXML(xmlData); //в xmlData лежит значение (проверила с помощью alert), например: //<root><status>1</status><operation_type>insert</operation_type><res>226</res></root> jQuery(fData).find("root").each(function () { //не выполняется тело var vStatus = jQuery(this).find("status").text(); if (vStatus == "-1") { jQuery("#info_msg").html("Внимание! Произошла ошибка! Повторите операцию либо обратитесь к разработчикам!"); return; } }
|
1 answer
jQuery when processing xml-code immediately starts counting from <root>
, so execute the code without find("root")
:
var fData = getXML(xmlData); var vStatus = jQuery(fData).find("status").text(); if (vStatus == "-1") { jQuery("#info_msg").html("Внимание! Произошла ошибка! Повторите операцию либо обратитесь к разработчикам!"); }
- removed, still does not work - I ’m living
- It works for me: var vStatus = jQuery ('<root> <status> 1 </ status> <operation_type> insert </ operation_type> <res> 226 </ res> </ root>'). Find ("status") .text (); alert (vStatus); If it does not work for you, then in
fData
nonsense, or correct xml. - ling - after fData = getXML (xmlData); if alert output this variable, it turns out that it is undefinde. What is wrong with him? The xml itself is normal - I live
- removed getXML and worked with XMLdata, everything plows. thanks - zhuzhu
|
poeration_type>insert</operation_type ? poeration vs operation
poeration_type>insert</operation_type ? poeration vs operation
- and here come and figure out whether it came the wrong answer from the server side, then you crookedly wrote the text - jmu