samedi 28 février 2015

HOW to implement this method with a promise


How would I use a promise to wait for the asynchronous geocode method to return a result and then return either true or false?



function LocationValidator(value, element, paras) {
var geocoder = new google.maps.Geocoder();

geocoder.geocode({ 'address': value }, function (results, status) { // called asynchronously
if (status == google.maps.GeocoderStatus.OK) {
return true;
} else {
return false;
}
});
}




Aucun commentaire:

Enregistrer un commentaire