asp classic - Data Not Filtering in Jquery Autocomplete -
i've followed examples http://jqueryui.com/autocomplete/
but instead of fixed array wanted dynamic array database
i've got working type won't filter results , if type letter doesnt exist in array, still shows full list.
search.asp
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>jquery ui autocomplete - default functionality</title> <link rel="stylesheet" href="//code.jquery.com/ui/1.12.0/themes/base/jquery-ui.css"> <link rel="stylesheet" href="/resources/demos/style.css"> <script src="https://code.jquery.com/jquery-1.12.4.js"></script> <script src="https://code.jquery.com/ui/1.12.0/jquery-ui.js"></script> <script> $(function() { $("#tags").autocomplete({ source: 'http://fullurl/autocomplete.asp' }); }); </script> </head> <body> <div class="ui-widget"> <label for="tags">tags: </label> <input id="tags"> </div>
autocomplete.asp
<% sconn = "driver={mysql odbc 5.1 driver}; server=server; port=3306; database=database; uid=username;password=password; option=3" set conn = server.createobject("adodb.connection") conn.open sconn ssql = "select * makes order makes asc;" set rst = server.createobject("adodb.recordset") rst.cursorlocation = 3 rst.open ssql, conn, 3, 1 output = "[" until rst.eof output = output & chr(34) & rst("makes") & chr(34) & "," rst.movenext loop output = left(output,(len(output)-1)) output = output & "]" response.write output rst.close conn.close %>
this result of autocomplete.asp: ["acer","dell","hp","lenovo","sony"]
any ideas i've done wrong or missed out
changed jquery follow , works fine now
<script> $(function() { $.getjson("autocomplete.asp", function(data) { $("#tags").autocomplete({ source: data }); }); }); </script>
Comments
Post a Comment