Created
February 9, 2015 10:16
-
-
Save cod3cow/e69dba7c7371947450df to your computer and use it in GitHub Desktop.
autocomplete city based on zip code / Autovervollständigung Ort bzw. Stadt anhand Postleitzahl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('#zip').blur(function() { | |
var city = $('#city'); | |
if (!city.val()) { | |
$.getJSON('http://www.geonames.org/postalCodeLookupJSON?&country=DE&callback=?', {postalcode: this.value }, function(response) { | |
if (!city.val() && response && response.postalcodes.length && response.postalcodes[0].placeName) { | |
city.val(response.postalcodes[0].placeName); | |
} | |
}) | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment