简体   繁体   中英

jQuery autocomplete : i can't see suggestion

I want to make autocomplete and getting data from database
This my code :

<script src="js/jquery-1.9.1.js"></script>
<script src="js/jquery-ui.js"></script>
<script>
$(function() {
  $( "#tags" ).autocomplete({
    source: 'consultation/commande_tags.php'
  });
});
</script>


<form method="post" action="#" class="formstyle1">
<input type="type" name="piece_a_commander" id="tags" placeholder="Réference "  />
</form>

the json page

 <?php
    if($_GET["term"]){
    include "includes/connexion_bdd.php";
    $ref=mysql_real_escape_string($_GET["term"]); 
    $rq_tags="SELECT * FROM piece WHERE reference_p LIKE '%".$ref."%'  ";
    $ret_tags=mysql_query($rq_tags) or die (mysql_error());
    $array = array();
    while ($tab_tags=mysql_fetch_array($ret_tags)){ 
    array_push($array,$tab_tags['reference_p']);
    }
    echo json_encode($array );
    }

    ?>

I cant see any suggestion,please help me to see where is the error?

try this code:

REPLACE

$().ready(function() {
 $( "#tags" ).autocomplete("consultation/commande_tags.php", {
    width: 108,
    matchContains: true,
    //mustMatch: true,
    //minChars: 0,
    //multiple: true,
    //highlight: false,
    //multipleSeparator: ",",
    selectFirst: false
});
});

CONNECTION :

<?php
$host="localhost";
$user="root";
$pass="";
$bdd="paralel";

// connexion
$con = mysql_connect($host,$user,$pass)or die(mysql_error());

//selection bdd

$db = mysql_select_db($bdd,$con)or die(mysql_error());

?>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM