Ajax Made Simple Part 8: Zip Code Lookup

Ever realize, when getting a user’s address, that knowing the zip code makes asking for the city and state unnecessary?

Here’s some simple code to look up the city and state from a zip code:

zip="90210"

req=Ajax("http://zip.elevenbasetwo.com?zip=" & zip)
If req.status=200 Then 'success
    MsgBox req.responseText
  Else 'failure
    MsgBox "Error: " & req.err.message
End If

The result is

{"country": "US", "state": "CA", "city": "BEVERLY HILLS"}