Zip Code to City, State for registration form Took me a couple of days (in between working on other projects) to get the code working, but now that I do have it working I would like to know if there is a way that I could make it work better, or clean up my act JavaScript/jQuery surrounding my JSON utilization skills.

I am using ASP.NET if that means anything to the JavaScript.

Here is the code, ASPX pertinent to the JavaScript only:

&lt;tr&gt;
    &lt;td&gt;
        &lt;asp:Label runat="server" ID="lblCity" Text="City:"&gt;&lt;/asp:Label&gt;&lt;/td&gt;
    &lt;td&gt;
        &lt;asp:TextBox runat="server" ID="txtCity" CssClass="textbox" Enabled="False" BackColor="#CCCCCC" &gt;&lt;/asp:TextBox&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
    &lt;td&gt;
        &lt;asp:Label runat="server" ID="lblState" Text="State:"&gt;&lt;/asp:Label&gt;&lt;/td&gt;
    &lt;td&gt;
        &lt;asp:TextBox runat="server" ID="txtState" CssClass="textbox" Enabled="False" BackColor="#CCCCCC"&gt;&lt;/asp:TextBox&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
    &lt;td&gt;
        &lt;asp:Label runat="server" ID="lblZip" Text="Zip Code:"&gt;&lt;/asp:Label&gt;&lt;/td&gt;
    &lt;td&gt;
        &lt;asp:TextBox runat="server" ID="txtZip" CssClass="textbox" TabIndex="6"&gt;&lt;/asp:TextBox&gt;&lt;/td&gt;
&lt;/tr&gt;


...

&lt;script&gt;
    $(document).ready(function () {
        $('#&lt;%=txtZip.ClientID%&gt;').blur(function (e) {
            getAddressInfoByZip($(this).val());
        })
        function response(obj) {
            console.log(obj);
        }
        function getAddressInfoByZip(zip) {
            var addr = {};

            if (zip.length &gt;= 5) {
                $.getJSON("https://maps.google.com/maps/api/geocode/json", { address: zip }, function success(results, status) {
                    for (var ii = 0; ii &lt; results.results[0].address_components.length; ii++) {
                        var street_number = route = street = city = state = zipcode = country = formatted_address = '';
                        var types = results.results[0].address_components[ii].types.join(","); 
                        if (types == "sublocality,political" || types == "locality,political" || types == "neighborhood,political" || types == "administrative_area_level_3,political") {
                            addr.city = (city == '' || types == "locality,political") ? results.results[0].address_components[ii].long_name : city;
                        }
                        if (types == "administrative_area_level_1,political") {
                            addr.state = results.results[0].address_components[ii].short_name;
                        }
                    };
                    document.getElementById('&lt;%=txtCity.ClientID%&gt;').value = addr.city;
                    document.getElementById('&lt;%=txtState.ClientID%&gt;').value = addr.state;

                    addr.success = true;
                    for (name in addr) {
                        console.log('### google maps api ### ' + name + ': ' + addr[name]);
                    }
                    response(addr);
                });
            } else {
                response({ success: false });
            }   
        }
    })
&lt;/script&gt;


I got the idea from SO and various places on the net, but I have hacked the code into this usable piece of script, but is it good code?
Global variables
In your function getAddressInfoByZip, you are declaring quite a number of global variables.
This is bad practice: all these variables should be local variables because they only serve a purpose in this function.
Now, you may not notice that you are creating a bunch of global variables. The evilness is happening in this line:
var street_number = route = street = city = state = zipcode = country = formatted_address = '';

The only local variable that is being created here is street_number; all those other variables are global.
Experiment
Run this in your console:
(function() { var foo = bar = &quot;Hello, World!&quot;; } )();

Then, try this:
console.log(foo);

You will get an error, because now that the anonymous function is out of scope, foo no longer exists.
Now, try this:
console.log(bar);

You will see

Hello, World!

Why? Well, since you created bar in that variable chain, it is created globally because there is no var keyword assigned to it.

This if statement is a little long:
if (types == &quot;sublocality,political&quot; || types == &quot;locality,political&quot; || types == &quot;neighborhood,political&quot; || types == &quot;administrative_area_level_3,political&quot;) {

I recommend you split up each conditional by line, like this:
if (types == &quot;sublocality,political&quot; || 
    types == &quot;locality,political&quot; || 
    types == &quot;neighborhood,political&quot; || 
    types == &quot;administrative_area_level_3,political&quot;) {


I'm confused by this line:
...document.getElementById('&lt;%=txtCity.ClientID%&gt;')...
Previously, you were using JQuery to interact with elements. Why did you suddenly stop using it here? If you are going to &quot;import&quot; JQuery, you might as well use it.

Inside the body of a function passed to $.getJSON, you are accessing a parameter passed in to the function called results. However, every time you are accessing it, you are accessing the 0th index of the results property of this results parameter.
Why don't you just store that in a variable? It would make your code a lot cleaner in a lot of places, and it increases readability because it doesn't make someone wonder why you are specifically accessing this value each time you want to use it.
Create a variable set to this value:
results.results[0];


I recommend creating an object of constants that are the different types. That way, you won't have to keep writing, for example,
&quot;sublocality,political&quot;

The object only has to be really simple: it's merely to store constants:
var Type = {
    SP: &quot;sublocality,political&quot;,
    LP: &quot;locality,political&quot;,
    AAL1P: &quot;administrative_area_level_1,political&quot;,
    ...
}

Note: I chose to name the identifiers using PascalCase for the object name and SHOUTCASE for the property names because most enumerated types are named like this.
Now, you can easily access a type like this:
Types.LP

This improves the readability of your code by a lot, because it gets rid of all the strings floating around your conditional statements.