javascript - Why doesn't this autosuggest work?

874

I've done some research and followed a tutorial exactly, with minor changes, but I can't seem to get this to work. No dropdown appears. Can you look at the code and tell me what is not happening?

<div class="ui-widget">
    <label for="skills">Skills: </label>
    <input id="skills">
</div>
<script>
$(function() {
    $( "#skills" ).autocomplete({
         width:448,
         delimiter: /(,|;)\s*/,
         lookup: <?php echo "'autocomplete(#skills)'" ?>
    });
});
</script>

<?php     
$servername = 'localhost';
$username = 'xx';
$password = 'xx';

$con = mysql_connect($servername,$username,$password);
mysql_select_db('c9', $con);

function autocomplete($inputName){
    $searchTerm = $_GET[$inputName];
    $query = mysql_query("SELECT * FROM clients WHERE fname LIKE '%".$searchTerm."%' ORDER BY fname ASC");
    while ($row = mysql_fetch_array(MYSQL_ASSOC)) {
        $data[] = $row['fname'];
    }
    //return json data
    echo json_encode($data);
}

?>

People are also looking for solutions to the problem: php - Requirements could not be re to an installable set of packages

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.