---------- Original Message ---------- To: jQuery (English) (jquery-en@googlegroups.com) From: David Decraene ([EMAIL PROTECTED]) Subject: [jQuery] Re: xml parsing - what am i doing wrong? Date: 21/1/2008 16:38:20
and even if it would return on time (synchronous call) you wouldn't really return it with datascape.getAllAnchors (return is wrapped inside the get object). This might or might not work depending on the timing: datascape.getAllAnchors = function(anchors){ $.get("projects/datascapes.xml",function(data){ anchors = $(data); }); } depends on how fast you need it, but it's better to wrap everything in a function that only gets executed once the data has been completely loaded? function dosomething(data){ var xx = data..... etc var thisDS = $('scape[title="'+UI.section+'"]', datascape.anchors); var dsAnchorVar = $('item[title="' + $proj + '"]',thisDS).parents('col').attr('title'); $.log("anchor "+$proj+"= "+ dsAnchorVar ); } $.get("projects/datascapes.xml",dosomething); David http://ontologyonline.org On Jan 21, 3:53 pm, David Decraene <[EMAIL PROTECTED]> wrote: > the get is asynchronous, > meaning that datascape.getAllAnchors is returned (nothing/undefined) > before the ajaxall (get) returns success. > > On Jan 21, 3:41 pm, "Alexandre Plennevaux" <[EMAIL PROTECTED]> > wrote: > > > Hello, > > > i'm loading a bit of xml and i'm trying to use the loaded data, but i 'm > > unsuccessful traversing it so far. Can you tell me what i'm doing wrong? > > > here is the loading code: > > > datascape.getAllAnchors = function(){ > > $.get("projects/datascapes.xml",function(data){ > > return $(data); > > }); > > > } > > > then further down, i need to retrieve an item's parent col element "title" > > attribute. > > > jQuery(function($){ > > > ... > > > var thisDS = $('scape[title="'+UI.section+'"]', datascape.anchors); > > var dsAnchorVar = $('item[title="' + $proj + > > '"]',thisDS).parents('col').attr('title'); > > $.log("anchor "+$proj+"= "+ dsAnchorVar ); > > > }); > > > the console keeps on showing dsAnchorVar as "undefined" > > > the xml file: > > > <?xml version="1.0" encoding="UTF-8"?> > > <datascapes> > > <scape title="title"> > > <col title="E"> > > <item title="electric_courtship_songs" /> > > </col> > > <col title="L"> > > <item title="liquidspace" /> > > <item title="liquidspace01" /> > > <item title="liquidspace02" /> > > <item title="liquidspace03" /> > > </col> > > <col title="S"> > > <item title="space-navigable-music" /> > > </col> > > </scape> > > <scape title="time"> > > <col title="2004"> > > <item title="electric_courtship_songs" /> > > </col> > > <col title="2003"> > > <item title="liquidspace" /> > > <item title="liquidspace01" /> > > </col> > > > </scape> > > </datascapes> > > > Thanks for any help, > > > Alexandre thanks a lot for all your help. what i need in fact is to get a reference table (stored in the xml file) that i will query many times, with different parameters. But with your various replies you already showed me more or less howto do it, i'll try to work it out , thanks again