Hi guys,
I'm implementing a small feature and kind of stuck.
I have a button to execute some action, such as
<input type="submit" value="My Button" onclick="javascript:DoSomething();" />
When the user clicks the button the function DoSomething is called.
function DoSomething()
{
var geocoder = new GClientGeocoder();
geocoder.getLocations(map.getCenter(), function SetField(response)
{
if (!response || response.Status.code != 200)
{
alert("Status Code:" + response.Status.code);
}
else
{
var place = response.Placemark[0];
$('#someHiddenField')[0].value = place.AddressDetails.Country.CountryNameCode;
}
});
}
Inside the function a callback function is defined, which performs an async operation that writes a city name in a form field. The problem is that the async callback will try to write in the field after the page is posted. Is there any was I can make the post process wait for the callback result? The callback is defined in the Google Maps API and I cannot avoid it.
Thanks in advance