Reputation: 12356
I have a field where user inputs Zip code. Based on the value entered I want to populate city and state. How i can do this in jQuery?
Upvotes: 1
Views: 1226
Reputation: 5907
You can use Google's Map / Geocoding API, here is a quick demo:
<script src="http://www.google.com/jsapi" type="text/javascript"></script>
<script type="text/javascript">
alert(google.loader.ClientLocation.address.city);
</script>
edit: Since the user is communicating directly with Google's servers, you don't even have to pass in an IP address, they figure it out. They may even use some additional points of data beyond IP address, but not sure.
Upvotes: 2