I'm trying to prevent a return false or undefined from the submit handler. I only want to return a value after the async results come back from google maps. Is this possible? My objective is to wait for google map results to come back before I go to my controller.
$('form').submit(function (e) {
var geocoder = new google.maps.Geocoder();
var address = $('#SearchQuery').val();
geocoder.geocode({ 'address': address }, function (results, status) {
if (status != google.maps.GeocoderStatus.OK) {
alert("Geocode was not successful for the following reason: " + status);
return false;
} else {
$("#latitude").val(results[0].geometry.location.G);
$("#longitude").val(results[0].geometry.location.K);
alert("Geocode successful");
return true;
}
});
//don't let anything get returned here, is a callback needed?
});
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire