I highly recommend you go to https://github.com/bassjobsen/Bootstrap-3-Typeahead . This is the same old old typeahead 2.x boot file, just maintained and fixed in its own repository, since bootstrap 3.0 skipped typeahead in favor of typeahead.js (which BTW is no longer supported at all). It will make life a lot easier for you.
After that, you can skip all the distortions and just do it:
$('#contact').typeahead( { source: jsonData, displayText: function(item) { return item.label }, afterSelect: function(item) { this.$element[0].value = item.value } })
updated script -> http://jsfiddle.net/qdgo651h/1/
Updated for comment. I believe that you are compromising the source part
$('.lookup').typeahead({ displayText: function(item) { return item.label }, afterSelect: function(item) { this.$element[0].value = item.value }, source: function (query, process) { return $.getJSON('json_autocomplete.php', { query: query }, function(data) { process(data) }) } })
must do it. Updated fiddle from comment below β http://jsfiddle.net/hwbnhbdd/1/ You can use http://myjson.com/ as an AJAX source in scripts, as in the update.
source share