Reputation: 6462
I'm trying to use geopages.org api to populate a city input field onblur of my zip code input field. I don't know what the problem is with my script.
<script>
$("#zip").blur(function() {
var city = $("#city");
var zip = $("#zip");
$.getJSON("http://www.geonames.org/postalCodeLookupJSON?postalcode=" + zip.val + "&country=US&username=myusername?", function(json){
data = json.postalcodes[0].placeName;
city.val(text);
});
}
});
</script>
I'm pretty sure it's a syntax error but my jQuery is not that good so I don't know where my issue is.
Upvotes: 0
Views: 1477
Reputation: 28608
You have one more }
than needed, try this:
$("#zip").blur(function() {
var city = $("#city");
var zip = $("#zip");
$.getJSON("http://www.geonames.org/postalCodeLookupJSON?postalcode=" + zip.val + "&country=US&username=myusername?", function(json){
data = json.postalcodes[0].placeName;
city.val(text);
});
});
Upvotes: 1