Jquery自动完成不过滤数据库中的结果

时间:2017-08-09 18:15:03

标签: jquery asp-classic

我有以下调用我的数据库的jquery:返回的字符串是:

[ “APPLE”, “DELL”, “HP”, “MICROSOFT”]

$(function(){
  $("#id-make").autocomplete({
      source: "actions/autocomplete.asp?data=1",
      minLength: 2,
  });
 });

但是,在我输入时,会显示所有结果:

enter image description here

我是否错过了jquery中的参数来过滤结果。

由于

Caique的更新:

这是创建字符串的自动完成的asp代码。我需要调用数据库来构建字符串,以便它始终是最新的

sSQL = "SELECT * FROM it_asset_makes ORDER BY make ASC;"

        Set rst = Server.CreateObject("ADODB.Recordset")
        rst.CursorLocation = 3
        rst.Open sSQL, Conn, 3, 1

        output = "["

        DO Until rst.EOF
        output = output & chr(34) & rst("make") & chr(34) & ","
        rst.movenext
        Loop

        output = left(output,(len(output)-1))
        output = output & "]"

        Response.Write output

输出= [“APPLE”,“DELL”,“HP”,“MICROSOFT”]

<input type="text" class="form-box-wide" id="id-make" name="frm-make" maxlength="30" autocomplete="off" /><br />

1 个答案:

答案 0 :(得分:0)

源中必要的传递数据= 1? 你能告诉我们你的HTML代码和autocomplete.asp吗?

HTML:

<div>
   <input type="text" name="id-make" id="id-make" value="" autocomplete="off" />
</div>

JS:

$(function(){
      var dataSource = ["APPLE","DELL","HP","MICROSOFT"];
    $("#id-make").autocomplete({
      source: dataSource,
      minLength: 2,
    });
 });

https://jsfiddle.net/fmvc14fj/2/