/ Published in: jQuery
                    
                                        
trugg
                
                            
                                Expand |
                                Embed | Plain Text
                            
                        
                        Copy this code and paste it in your HTML
var timeoutLocalita = 0;
$("#localita").live('keyup', function() {
clearTimeout(timeoutLocalita);
timeoutLocalita = setTimeout('checkPosizione()', 500);
});
function checkPosizione() {
console.log('vado con: ' + $("#localita").val() );
$.post('/elementi/geotag', { where: $("#localita").val() }, function(res) {
console.log(res);
if(res.status == 'OK') {
$("#localitaHelper").html(
'Selezionato: ' +
res.results[0].address_components[2].long_name +
'<input type="hidden" name="lat" value="'+ res.results[0].geometry.location.lat + '" /><input type="hidden" name="lng" value="'+ res.results[0].geometry.location.lng +'" />');
} else {
$("#localitaHelper").html('Risultato: Localitàpoco accurata.');
}
}, 'json');
}
Comments
 Subscribe to comments
                    Subscribe to comments
                
                