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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:27:13+00:00 2026-05-26T16:27:13+00:00

I am trying to access object using ajax in spring MVC. So its like

  • 0

I am trying to access object using ajax in spring MVC. So its like I have 2 drop downs for country and states when I select country it should update states accordingly. What I have done till now is in my .jsp file

<script>
    function modifyList() {         
        $.post("checklist.html", { country: $('#country').val() }, 
                function(data) { alert(data); });
    }
</script>   

<body>  
    <form:form id="flist" commandName="list">
        <table>         
            <tr>
                <td>
                    <form:label path="country"> Country </form:label>
                </td>
                <td>
                    <form:select path="country" multiple="false" onchange="modifyList()">
                        <form:options items="${list.country}" />
                    </form:select>
                </td>
            </tr>
            <tr>
                <td>
                    <form:label path="state"> State </form:label>
                </td>
                <td>
                    <form:select path="state" multiple="false">
                        <form:options items="${list.state}" />
                    </form:select>
                </td>
            </tr>   
        </table>
</form:form>
</body>

In my controller I have

@RequestMapping(value = "/{path}/checklist", method = RequestMethod.POST)   
public @ResponseBody String list(@RequestParam("country") String country) { 
    System.out.println("selected country" + country);
    return country;
}

This works fine and returns me the country name in alert but my problem is I want to populate my state drop down according to the country selected. Is it possible that I can return the whole list object? If yes then how I can read that object and populate my state dropdown?

  • 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-26T16:27:14+00:00Added an answer on May 26, 2026 at 4:27 pm

    AFAIK the Spring tags don’t know anything about Ajax, so you’d need to use JavaScript to remove any existing options and add the new ones returned from the Ajax call.

    There are a number of plugins listed on the jQuery site; YMMV. I might consider just doing it by hand, since the code is relatively short.

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

Sidebar

Related Questions

I am trying to access member variables of a class without using object. please
I am using .Net Remoting and trying to access a remote object modified in
I am trying to access one class object's data member by using a constant.
I am trying to access a flash shared object using sharedObject.getLocal(sharedObjectName); But, it always
I am trying to access a property of instance object using the following code
Using Delphi XE. When trying to access a Delphi interface object from a DLL,
I'm trying to access data within a JSON object I create using json_decode (based
I'm trying to access the output from the listFields geoprocessing object using the following
I am trying to access Outlook 2007 from C#. I have installed the PIA
I have some xml data and I am trying to access some elements. 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.