I'm toying with the new autocomplete in jQuery 1.8-UI. I've provided data in the following format
["val1", "val2", "val3"]
This is coming from a stored procedure but output as a string. For some reason this doesn't work at all, however, if I supply the same data using a javascript variable
var data = ["val1", "val2", "val3"];
Then this works fine.
<script type="text/javascript">
$(function()
$("#txtClient").autocomplete({
source: "/intranet/common/scripts/IntranetLists.aspx?ListType=C"
});
});
</script>
I've got a page which supplies whatever data I want using query strings. It's more temporary, but it worked when I previously used bassistence's autocomplete.
Any ideas?
EDIT
The source simply outputs an entry on separate lines. Now the output does it with JSON format. What I don't understand is how the input provides the data as a query to the source of data. As I say, I'm using a script which should get called every time I enter a new key.
Here's the code I've got (take into account this worked fine with a third-party autocomplete plugin)
<%
Dim MyCmd As New dbExact("proc_Intranet_Lists")
MyCmd.cmd.Parameters("@List").Value = Request.QueryString("ListType")
If Request.QueryString("Top") <> Nothing Then
MyCmd.cmd.Parameters("@Top").Value = Request.QueryString("Top")
End If
MyCmd.cmd.Parameters("@Code").Value = Request.QueryString("term")
MyCmd.cmd.Connection.Open()
Dim results As New StringBuilder()
results.Append("[")
Dim dr As SqlDataReader = MyCmd.cmd.ExecuteReader
If dr.HasRows Then
While dr.Read
results.AppendLine("'" + dr(0).ToString() + "',")
End While
Else
results.Append("None Found")
End If
results.Remove(results.Length - 2, 2)
results.Append("]")
Response.Write(results.ToString())
results = Nothing
MyCmd.cmd.Connection.Close()
MyCmd = Nothing
%>
The documentation for the new autocomplete doesn't state anywhere that the query string passed is actually called "term" (which I found out from the search.php file). I'm doing this in VB.NET.