 <p>Try this:</p> <pre><code>$('.typeahead').typeahead({ source: function (query, process) { return $.get('data.php', { query: query }, function (data) { return process(data.options); }); } }); &lt;?php $mysqli = new mysqli("localhost", "root", "", "disbursements"); $query = 'SELECT payee_name FROM payees'; if (isset($_POST['query'])) { // Now set the WHERE clause with LIKE query $query.= ' WHERE payee_name LIKE "%' . $_POST['query'] . '%"'; } $return = array(); if ($result = $mysqli-&gt;query($query)) { // fetch object array while ($obj = $result-&gt;fetch_object()) { $return['options'][] = $obj-&gt;payee_name; } // free result set $result-&gt;close(); } // close connection $mysqli-&gt;close(); $json = json_encode($return); echo $json; ?&gt; </code></pre>