How to use autocomplete and work with different input

How to use autocomplete and work with different input

I have a form that has a zip code input and state dropdown list (pre-populated).   The zip code input is before the state dropdown and was looking for a way where when I enter the 5th numeric value of a zip code it calls the autocomplete and then it calls something like http://ZiptasticAPI.com/90120 and then based on the return state it will set the dropdown for the user.

So wondering if anyone has a similar function or is autocomplete not the right way of doing this?

Thanks in advance.