[jQuery] Re: Ajax scoping problem

2008-01-28 Thread [EMAIL PROTECTED]
On Jan 22, 2:57 pm, yves coor <[EMAIL PROTECTED]> wrote: > I don't think I am but maybe I'm judging this wrongly. > I call two functions: > > readXml(...); > displayPlayer(...); > > The second one uses the global var myarray but it's always undefined. I think that that's where the asynchronous

[jQuery] Re: Ajax scoping problem

2008-01-22 Thread yves coor
I don't think I am but maybe I'm judging this wrongly. I call two functions: readXml(...); displayPlayer(...); The second one uses the global var myarray but it's always undefined. It must definitely be related to the timing of the asynchronous call though. If I pass the values returned by the

[jQuery] Re: Ajax scoping problem

2008-01-22 Thread David Decraene
also If you do something like this (don't know if you do): var myarray = new Array(); function readXml(){ ..ajax.. } function handleXML(xml) { myarray[i] == ...} var x = myarray.length; then x will always be 0 because myarray.length get's executed before the ajax call returns success (async

[jQuery] Re: Ajax scoping problem

2008-01-22 Thread David Decraene
why not: var myarray = new Array(); function handleXML(xml) { $(xml).find("something somethingelse").each(function(){ myarray.push( $(this).text()); }); Can't see why that wouldn't work. David http://OntologyOnline.org On Jan 22, 11:53 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>