I am having trouble extracting data from the following function which only works with an alert(content) as the next line but obviously this has to be removed! What am I doing wrong please?
var address = [];
var content;
geocoder.geocode({'latLng': Marker.getPosition()}, function(responses, status) {
if (status == google.maps.GeocoderStatus.OK) {
if (responses && responses.length > 0) {
address = (responses[0].formatted_address).split(',');
for (i =0; i < address.length; i++) {
content += '<div>' + address[i] + '</div>';
}
}
}
});
content += content '<br>Last line</div>';
The above line does not include the above geocode content at all.
Callback is async, you can use the value only inside the callback.
Will execute BEFORE the callback fires.
Please read this regarding handling server data got by AJAX.