Posts

Showing posts from February, 2015

Typeahead Implementation in PHP/MySQL

DEMO
First, you need to include all the necessary files for this to work. Place these three files in the head section of your page..

jquery-1.10.2.min.js bootstrap.min.jsbootstrap3-typeahead.min.js
Then, this script:

$(document).ready(function () { var objects = []; var map = {}; $('#person').typeahead({ source: function (query, process) { $.ajax({ url: 'get_person.php', type: 'POST', dataType: 'JSON', async: true, success: function (data) { objects = []; //resets the objects map = {}; //to avoid duplication $.each(data, function (i, object) { map[object.full_name] = object; objects.push(object.full_name); }); process(objects); } }); }, //end source update…