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 9189487
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:14:54+00:00 2026-06-17T20:14:54+00:00

I am trying to display autocomplete list using JQuery and Spring 2.5.6, but I

  • 0

I am trying to display autocomplete list using JQuery and Spring 2.5.6, but I am getting json to the front end, but I can’t able to display it.

 $(function() {
    $("#globalSearch").autocomplete({
        source: function(request, response) {
            $.ajax({
                url: "${pageContext.request.contextPath}/autoSearch.htm",
                data: {
                    term : request.term
                },
                dataType: "json",
                contentType: "application/json; charset=utf-8",
                success: function(data) {
                    // this is the alert output its displaying:{"list":["ernst","ernst&nbsp"]} 
                    alert(JSON.stringify(data, null, 4));
                    response($.map(data, function(item) {
                        //its not alerting anything here
                        alert(JSON.stringify(item, null, 4));
                        return{
                            value: item.list
                        };
                    }));
                }
            });
        }
    });
});

here is my spring controller code:

@RequestMapping(method = RequestMethod.GET, value = "/autoSearch.htm")
public ModelAndView autoSearch(
        @RequestParam(value = "term", required = false) String term
       ) throws ParseException, IOException {

    if (logger.isDebugEnabled()) {
        logger.debug("inventoryHandler called");
    }

    Map<String, Object> model = new HashMap<String, Object>();
    int i = 0;
    model.put("list", getBaseModel().getSearchServiceBean().autoCompleter(term));
    return new ModelAndView("jsonView", model);
}

can anyone please tell me how can I display the autocomplete list.

Thanks in Advance,

Best Regards,
Raja.

  • 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-06-17T20:14:55+00:00Added an answer on June 17, 2026 at 8:14 pm

    @RequestMapping(method = RequestMethod.GET, value = “/autoSearch.htm”)
    public ModelAndView autoSearch(
    @RequestParam(value = “term”, required = false) String term
    ) throws ParseException, IOException {

        if (logger.isDebugEnabled()) {
            logger.debug("inventoryHandler called");
        }
    
        Map<String, Object> model = new HashMap<String, Object>();
        model.put("list", getBaseModel().getSearchServiceBean().searchAutoComplete(term));
        return new ModelAndView("jsonView", model);
    }
    

    and in views.properties file view should be set like

    jsonView.(class)=org.springframework.web.servlet.view.json.JsonView

    and in javascript the autocomplete will work by using the following code:

            $("#searchEmail").autocomplete({
                source: function(request, response) {
                    ajaxCall(request, response);
                },
                select: function(event, ui) {
                    $("#searchEmail").val(ui.item.value);
                    $("#emailSearch-form").submit();
                }
            });
    
            function ajaxCall(request, response) {
                $.ajax({
                    url: "${pageContext.request.contextPath}/autoSearch.htm",
                    data: {
                        term : request.term
                    },
                    dataType: "json",
                    contentType: "application/json; charset=utf-8",
                    success: function(data) {
                        response($.map(data.list, function(item) {
                            return{
                                label: item,
                                value: item
                            };
                        }));
                    }
                });
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to write some JQuery using the AutoComplete plugin to display a list
I'm trying to use the new autocomplete function in jQuery UI, but I'm having
I am trying to display jSON data in jQuery autocomplete, and everything works fine
Currently I display a list of supplier using a Popup LOV but I'm trying
I am trying to display some cities in autocomplete using jquery and when any
Hi I am trying to autocomplete a list of cities, but the json object
I am trying to display data that I am getting from server through json.
http://community.sciencecareers.org/mt-static/plugins/CommunityPlus/js/autocomplete/ http://community.sciencecareers.org/mt-static/plugins/CommunityPlus/js/autocomplete/demo/ Trying to programmatically trigger the display of the autocompletion list results. This,
I'm trying to navigate the autocomplete dropdown using arrow keys. JSON { employees:[ {
I'm trying to implement autocomplete feature. I've looked through https://github.com/crowdint/rails3-jquery-autocomplete but I had to

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.