I tried many ways to get values from my asynchronous function. But, the only thing I could do is get this value using another asynchronous function. Is it not possible to store it into a global variable which will be used then to send datas with AJAX?
Here is my code :
geocoder.geocode({'latLng': latlng}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK)
{
if (results[0])
{
var elt = results[0].address_components;
for(i in elt)
{
if(elt[i].types[0] == 'postal_code')
{
getResults(elt[i].long_name.substring(0, 2));
}
}
}
}
else
{
alert("Le geocodage n\'a pu etre effectue pour la raison suivante: " + status);
}
});
getPostalCode(source, function(dpt){
alert(dpt);
})
This is not duplication, I read How do I return the response from an asynchronous call? but, I couldn't find what I needed.