Appcelerator/Titanium - Call variable from within function
<p>I have some code as below, which gets the current location and then creates a variable with that information. I would like to use that variable outside of the function but so far everything I've tried has failed. The alert below works if it's within the function, but as soon as you put it outside it's blank. I've also tried creating global variables in alloy.js but that didn't seem to work either. I know this is very simple but need some more ideas :) </p>

<pre><code>Titanium.Geolocation.getCurrentPosition(function(e) {
if (e.error) { 
    alert('Error: ' + e.error); 
} else { 

    var params = {
        latitude: e.coords.latitude,
    };

    return params;

} 
});



alert(params);
</code></pre>