How should I put this XML object into a javascript dictionary?

GN-001

New Member
How should I put this XML object into a javascript dictionary? XMLcoming in from get_objectives.php:\[code\]<container> <objective> <id>1</id> <type>thing</type> <name>banana</name> <date_added>2012-05-08 21:13:01</date_added> <released>2012-05-08 22:47:27</released> </objective> <objective> <id>2</id> <type>thing</type> <name>hammock</name> <date_added>2012-05-08 21:13:01</date_added> <released>2012-05-08 22:47:27</released> </objective></container>\[/code\]The javascript that doesn't work, that I"m trying to fix:\[code\]function updateObjectives(){ $.post('scripts/get_objectives.php', {}, function(xml){ $(xml).find("objective").each(function(i){ objectives = {} objectives['id'] = $('id', xml).text() console.log("objectives["+i+"].id = "+objectives.id) }) })}\[/code\]Based on the console output below, it appears that the \[code\]$('id', xml).text()\[/code\] call that I am trying isn't stuck inside the function handling the find("objective").each call:\[code\]objectives[0].id = 12objectives[1].id = 12\[/code\]
 
Back
Top