This may be useful for you. I use the extension for Typeahead, which allows you to call remote data sources. It comes with the onselect() callback function, where you can do what you want.
typeahead gist extension
Here is a sample code:
initialization: function() { this.user = new User();
So basically in my code, when I query my DB, I return a JSON that sets the value of each selection for any data that I transferred from my ajax.
With onselect(obj) I pass obj to my callback, and I just attach it as data to the input element. But you can easily add your own code that uses the user data (user.id) that you already have, and do what you do, along with the value that you have chosen of your choice. The value of user.id should be available in your onselect() as long as it is in the right amount of things.
source share