我的自动完成搜索框有问题:
必须将数据库中找到的值链接起来。
我该怎么办?
<style>
.ui-autocomplete-loading {
background: white url("http://www.guiza.net/fotos/wp-content/plugins/nextgen-gallery/admin/css/images/ui-anim_basic_16x16.gif") right center no-repeat;
}
</style>
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script>
$( function() {
var cache = {};
$( "#birds" ).autocomplete({
minLength: 2,
source: function( request, response ) {
var term = request.term;
if ( term in cache ) {
response( cache[ term ] );
return;
}
$.getJSON( "search.php", request, function( data, status, xhr ) {
cache[ term ] = data;
response( data );
});
}
});
} );
</script>
<div class="inputCerca ui-widget">
<input type="text" name="cerca" placeholder="A cosa vorresti giocare?" id="birds">
</div>
在文件search.php中,我生成了arrey:
CONNESSIONE AL DB +查询
$ array [] =“ $ ricerca [giochi_nome]”;