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

  • Home
  • SEARCH
  • 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 6955933
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T14:48:06+00:00 2026-05-27T14:48:06+00:00

Though the title might be either too specific or too vague, I have a

  • 0

Though the title might be either too specific or too vague, I have a question in regards to what the Autocomplete widget sends to my servlet when it attempts to retrieve a JSON object. The source option of the Autocomplete allows me to specify a URL to, in this case, my servlet where it expects a JSON object to be returned. Unfortunately, the jQuery UI Autocomplete documentation has me a bit confused:

When a String is used, the Autocomplete plugin expects that string to point to a URL resource that will return JSON data. It can be on the same host or on a different one (must provide JSONP). The request parameter “term” gets added to that URL.

Now, does this mean that if my servlet URL were something like: “MyServlet,” would the new URL be “MyServlet?term“? I send multiple AJAX requests to this servlet, and I normally decipher what procedure I should take with each based on a parameter “command” that I post with each AJAX request. So, when the Autocomplete makes its request to my servlet, what exactly do I check to see if it’s asking for this particular JSON? For every other request, I do something like this:

if(request.getParameter("command").equals("getUsers") {
    // Code to handle Getting Users...
} else if(request.getParameter("command").equals("getEvents") {
    // Code to handle Getting Events...
} else if(request.getParameter("command").equals("getBugs") {
    // Code to handle Getting Bugs...
}

How can I check to see if the request is coming from the Autocomplete? Could I tag on this “command” parameter to the URL that I pass into the source, kind of like “MyServlet?command=autocomplete” to let it know, or would this even be necessary?

EDIT: So after rereading the documentation, it actually sounds as though using a string referencing a URL as the source will basically make a request to that source each time it makes a search, and that “term” parameter simply carries what was in the search box when it began. In other words, does this mean that it doesn’t simply load a JSON of all possible terms and just uses it like an array? Rather, it goes to fetch the possibilities at each search?

  • 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-27T14:48:07+00:00Added an answer on May 27, 2026 at 2:48 pm

    it actually sounds as though using a string referencing a URL as the source will basically make a request to that source each time it makes a search, and that “term” parameter simply carries what was in the search box when it began. In other words, does this mean that it doesn’t simply load a JSON of all possible terms and just uses it like an array? Rather, it goes to fetch the possibilities at each search?

    Yes this is correct. When you use a remote source, you are responsible for doing the filtering before sending back candidates for autocompletion.

    Check out the remote demos on the jQueryUI autocomplete demos page. Look in firebug as the requests are fired off to see what the request looks like.

    If you need to send along extra parameters with a request, you can pass a function to the source option and make your own AJAX request:

    $("...").autocomplete({ 
        source: function (request, response) {
            $.ajax({
                data: { term: request.term, command: 'autocomplete' },
                /* other options */
                success: response
            });
        }
    });
    

    Using this method basically allows you to provide any arbitrary data source you want. The key parts are calling the response callback with the autocomplete candidates, and getting the term that was searched for using request.term.

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

Sidebar

Related Questions

The title might be a little weird but let me explain. I have User,
The title is a bit more specific than my actual goal: I have a
Ok, the title might sound a bit vague but I really can't think of
Here's a restatement of the rather cryptic title question: Suppose we have a Prototype
Does that title sound confusing? I thought it might well anyways. When I person
Though the title says everything, I want to let you know the particular scenario
My title sums this up pretty well. My first though it to provide a
I have gone through this to change the color of my title bar. I'm
As in title I have a page that calls a lot of webservices through
Though the question is generic, I would mention the scenario which sparked the query.

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.