get values from asynchronous callback
<p>Hello am trying to get the location for each loop. Yahoo placemaker is used to get locations from text variables of an array.Within each loop am sending the location to an outer function but I am not getting the values. Does anyone know what am doing wrong? Thanks!</p>

<pre><code>    function replace_undefined(array, text_array) {
        console.log(text_array);
        for (i = 0, l = text_array.length; i &lt; l; i++) {
            var text = array[i].text;
            Placemaker.getPlaces(text, function (o) {
                console.log(o);
                if ($.isArray(o.match)) {
                    if (o.match[0].place.name == "Europe" || o.match[0].place.name == "United States") {
                        var location = o.match[1].place.name;
                        getLocation(location);
                    }
                    if ($.isArray(o.match)) {
                        if (o.match[0].place.name !== "Europe") {
                            var location = o.match[0].place.name;
                            getLocation(location);
                        }
                    }
                }
                if (!$.isArray(o.match) &amp;&amp; o.error == "no locations found") {
                    var location = "";
                    getLocation(location);

                }
                if (!$.isArray(o.match) &amp;&amp; o.error !== "no locations found") {
                    var location = o.match.place.name;
                    getLocation(location);
                }
            });
        }

        function getLocation(n) {
            return function () {
                console.log('Location: ' + n);
            };
        }


    }
</code></pre>
