jQuery not reading or counting nodes of XML file correctly -



jQuery not reading or counting nodes of XML file correctly -

this question has reply here:

how homecoming response asynchronous call? 11 answers

i have xml document:

<?xml version='1.0' ?> <root> <row> <title>homeward bound</title> </row> <row> <title>escape witch mountain</title> </row> .... .... </root>

my jquery read xml is:

$(document).ready(function () { var data; $.ajax({ type: "get", url: "titles.xml", datatype: "xml", success: function (e) { info = e; }, error: function () { alert("the xml file not processed correctly."); } }); alert($(data).find("root row").length);

... .. .

the alert shows 0 - despite there beingness several records.

is there wrong way i'm reading xml file - or ".find" wrong?

thanks help, mark

scope of success argument remains in method only. set value variable variable , utilize variable outside. or write code in success function:

$(document).ready(function () { $.ajax({ type: "get", url: "titles.xml", datatype: "xml", success: function (e) { alert($(data).find("root row").length); }, error: function() { alert("the xml file not processed correctly."); }}); });

jquery xml xml-parsing

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -