简体   繁体   中英

tokeninput jquery php : show all results ever

i need help on my script.

I create my file PHP :

# Perform the query
$query = sprintf("SELECT ID,CATEGORIA from INTUITcategoria ORDER BY CATEGORIA", mysql_real_escape_string($_GET["q"]));
$arr = array();
$rs = mysql_query($query);

# Collect the results
while($obj = mysql_fetch_object($rs)) {
    $arr[] = $obj;
}

# JSON-encode the response
$json_response = json_encode($arr);

# Return the response
echo $json_response;

and JSON result seems ok and is this :

 {"ID":"73","CATEGORIA":"RADIOMICROFONI"}, {"ID":"68","CATEGORIA":"ACCESSORI RADIOMICROFONI"}, {"ID":"34","CATEGORIA":"ACCORDATORI "}, ............ 

Now set my html file in this way :

>     <div>
>         <input type="text" id="demo-input-facebook-theme" name="blah2" />
>         <input type="button" value="Submit" />
>         <script type="text/javascript">
>         $(document).ready(function() {
>             $("#demo-input-facebook-theme").tokenInput("../categorieautocomplete.php",
> {
>                 theme: "facebook"
>             });
>         });
>         </script>
>     </div>

But i have a problem. When i digit "ACC" into input text, i receive entire list and not filter on "ACC".

Have an ideas for solve this ?

Thank's in advance

Stefano

$("#demo-input-facebook-theme").tokenInput("../categorieautocomplete.php",

You are not passing the parameter to the script, so if it is empty then it give you all rows. You need to pass the "q" parameter to the script.

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