Here a very rough sketch of some code that will get you started. By no means is it complete, but it should give you a good jumping off point. Hope it helps
$("#mySearchBox").change(function(){
/*
send a ajax request to receive a json object.
We use the callback function to populate the
a div tag "autocomplete" with the names
*/
$.getJSON("http://myurl.com/myPage?search="+$(this).val()
function(data){
$.each(data.items, function(i,item){
/*
Assume item looks like this
item = {[{"address": 100 Main st",
"name": "Bob and Joe's Dinner"],
...
}
*/
/* Populate autocomplete with new spans
We use the text attribute to hold the address
You may want to look in to jquery data() feature.
*/
$("#autoComplete").append('<span text="'+ item.address +
'" class="searchResult">'+ item.name +'</span>');
});
});
});
$("#autoComplete .searchResults").click(function(){
/*
Here we handle what the user clicks on.
Pull out the address from the attr and
put that back in the mySearchBox
*/
var address = $(this).attr("text");
//Load the adress back int the textfield
$("#mySearchBox").val = address;
});