Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 714157
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T05:02:38+00:00 2026-05-14T05:02:38+00:00

I’m toying with the new autocomplete in jQuery 1.8-UI. I’ve provided data in the

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T05:02:38+00:00Added an answer on May 14, 2026 at 5:02 am

    Realistically, I should write a tutorial up for this because there’s not much documentation around. If you want to use jQuery’s new Autocomplete in jQuery-UI 1.8 then here’s how you do it.

    Personally, I used a generic web handler. I’m under the assumption these are better because they don’t go through the regular request pipeline and instead only have two “elements”, a property, and a sub-routine called ProcessRequest.

    The way I do it is I’ve written a stored procedure which takes set arguments to determine what autocomplete I want. For example, if I want to use the autocompleter to list some countries, or I want to use it to list the names of employees, then I pass a certain query string to determine what I want back. This makes it very flexible.

    <%@ WebHandler Language="VB" Class="Autocomplete" %>
    
    Imports System
    Imports System.Web
    Imports System.Collections.Generic
    Imports System.Web.Script.Serialization
    
    Public Class Autocomplete : Implements IHttpHandler
    
      Public Class AutocompleteItem
        Public id As String
        Public value As String
      End Class
    
      Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
        context.Response.ContentType = "text/plain"
    
        Dim conn As New SqlConnection(ConfigurationManager.ConnectionStrings("YourConnectionString").ToString)
        Dim cmd As New SqlCommand("YourStoredProcedure", conn)
        cmd.CommandType = CommandType.StoredProcedure
        With cmd.Parameters
          .Add(New SqlParameter("@List", 22, 10, 1, False, 0, 0, "", 512, context.Request.QueryString("ListType")))
          .Add(New SqlParameter("@Code", 22, 12, 1, False, 0, 0, "", 512, context.Request.QueryString("term")))
          .Add(New SqlParameter("@Top", 16, 0, 1, False, 0, 0, "", 512, context.Request.QueryString("Top")))
        End With
        conn.Open()
    
        Dim results As New StringBuilder()
        Dim dr As SqlDataReader = cmd.ExecuteReader
        Dim items As New List(Of AutocompleteItem)
        Dim serializer As New JavaScriptSerializer()
    
        While dr.Read
          Dim autocomplete As New AutocompleteItem
          autocomplete.id = dr(0)
          autocomplete.value = dr(1)
          items.Add(autocomplete)
        End While
    
        Dim arrayJson As String = serializer.Serialize(items)
        context.Response.Write(arrayJson)
        conn.Close()
      End Sub
    
      Public ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable
        Get
          Return False
        End Get
      End Property
    End Class
    

    I’m sure there’s many other ways of doing this, but this is just what worked for me. I use the AutocompleteItem CDT because the named variables are what are used in jQuery’s Autocomplete. By default, it uses id and value. You can specify anything else you want, but then you have to go and format your items yourself using the events provided in jQuery.

    Fortunately .NET lets you serialize the data, but you can do so in PHP as well using json_encode. You can find the PHP example in the jQuery UI download.

    Finally, here’s the jQuery I used. I have a zero delay because it’s a fast, local server.

    <script type="text/javascript">
        $(function() {
          $("#txtClient").autocomplete({
            source: "/intranet/common/scripts/Autocomplete.ashx?ListType=Addresses",
            minLength: 2,
            delay: 0
          });
        });
    </script>
    

    Hopefully this will help you when using jQuery UI 1.8’s Autocomplete.

    EDIT If anyone has any recommendations on how to improve the generic handler, feel free to showo me. I notice I’m re-instantiating the AutocompleteItem object each time, however if you don’t do this it will keep the old values for some reason, despite re-initializing the variables with new values. Cheers.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Does anyone know how can I replace this 2 symbol below from the string
I am currently running into a problem where an element is coming back from
I have some data like this: 1 2 3 4 5 9 2 6
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
this is what i have right now Drawing an RSS feed into the php,
I am reading a book about Javascript and jQuery and using one of the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.