Created
June 10, 2015 14:30
-
-
Save ChristopherDosin/64a0eb8adaa1879b0282 to your computer and use it in GitHub Desktop.
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
$('#zipcode').bind('keyup change', function(e) { | |
if ($(this).val().length > 4) { | |
var ort = $('#city'); | |
$.getJSON('http://www.geonames.org/postalCodeLookupJSON?&country=DE&callback=?', {postalcode: this.value }, function(response) { | |
if (response && response.postalcodes.length && response.postalcodes[0].placeName) { | |
ort.val(response.postalcodes[0].placeName); | |
} | |
}) | |
} else { | |
$('#city').val(''); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment