簡體   English   中英

jQuery自動完成功能:我看不到建議

[英]jQuery autocomplete : i can't see suggestion

我想進行自動完成並從數據庫中獲取數據
這是我的代碼:

<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>

json頁面

 <?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 );
    }

    ?>

我看不到任何建議,請幫助我看看錯誤在哪里?

試試這個代碼:

更換

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

連接方式:

<?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)或die(mysql_error());

?>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM