I'm calling a web service that returns an array. I have a function that just
displays the result returned. I'm getting [object, object] when I trace the
result. How do I pull a variable returned from the array like city? I've tried;
details.onResult=function(result){
trace(result.city); // equals undefined
trace(result); // equals [object, object]
}
please help;
what am i missing
Kaare - 31 Oct 2005 18:48 GMT
You have to parse through the array, which per default does not have named
indexes. It goes something like this:
details.onResult=function(result){
for(var i=0; i<result.length;i++){
trace("result["+i+"] = "+result);
}
}
C-Rock - 31 Oct 2005 19:37 GMT
I'm still getting object object... Here's what my trace says.
result[0]=[object Object]
any ideas???
Kaare - 31 Oct 2005 20:32 GMT
That would make sense if what's in the first index of the array is another
array, which could have been traced like this: trace("result[0][0] =
"+result[0][0]);
But I just saw an error, so it actually makes sense it outputs [object] again.
Revised script:
details.onResult=function(result){
for(var i=0; i<result.length;i++){
trace("result["+i+"] = "+result);
}
}
C-Rock - 31 Oct 2005 20:35 GMT
C-Rock - 31 Oct 2005 20:35 GMT
Kaare - 31 Oct 2005 20:35 GMT
Sorry 'bout that by the way ;)