Created
May 30, 2011 01:20
-
-
Save campreb/998330 to your computer and use it in GitHub Desktop.
AddressFinder using jQuery UI autocomplete
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$("#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