Skip to content

Instantly share code, notes, and snippets.

@Samnan
Forked from campreb/addressfinder-jqueryui.js
Created June 24, 2011 11:23
Show Gist options
  • Save Samnan/1044601 to your computer and use it in GitHub Desktop.
Save Samnan/1044601 to your computer and use it in GitHub Desktop.
AddressFinder using jQuery UI autocomplete
$("#ac_me").autocomplete({
source: function( request, response ) {
$.getJSON("http://api.addressfinder.co.nz/search/location?callback=?",
{q:request.term,key:"YOUR-API-KEY"},
function( data ) {
response( $.map( data.results, function( item ) {
return {
label: item.a,
pxid: item.pxid
}
}));
}
);
},
select: function(event,ui){
//Fetch extended data on the location.
$.getJSON("http://api.addressfinder.co.nz/info?callback=?", {pxid:ui.item.pxid,key:"YOUR-API-KEY"},
function(data){
console.log(data);
}
);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment