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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T15:33:26+00:00 2026-06-12T15:33:26+00:00

I have form and I want to grab the data inserted by users and

  • 0

I have form and I want to grab the data inserted by users and then convert them json format.
So first here is my form—

<form id="patient_form" action="#" class="form-horizontal">
            <div class="control-group">
                <label class="control-label" for="firstName"> First Name<em>*</em></label>
                <div class="controls">
                    <input type="text" id="firstName" class="required" maxlength="100"
                        placeholder="First Name" />
                </div>
            </div>
            <div class="control-group">
                <label class="control-label" for="middleNameInitial">
                    Middle Name Initial</label>
                <div class="controls">
                    <input type="text" id="middleNameInitial"
                        placeholder="Middle Name Initial" class="input-small"
                        maxlength="1" />
                </div>
            </div>
            <div class="control-group">
                <label class="control-label" for="lastName"> Last Name <em>*</em></label>
                <div class="controls">
                    <input type="text" id="lastName" placeholder="Last Name"
                        class="required" maxlength="100" />
                </div>
            </div>

            <div class="control-group">
                <label class="control-label" for="dateOfBirth"> Date Of
                    Birth</label>
                <div class="controls">
                    <input type="text" id="dateOfBirth" class="required" />
                </div>
            </div>

            <div class="control-group">
                <div class="controls">
                    <button type="button" class="btn btn-primary"
                        onclick="savePatientInfo()">Save Changes</button>
                    <button type="button" class="btn"
                        onclick="cancelPatientInfoForm()">Cancel</button>
                </div>
            </div>
        </form>

And then I want to send back them to server. And for server side code, I’m using spring mvc and client side I’m using JQuery.

Now how can I do it? I need two things basically,

  1. Ajax call (JavaScript function to which will basically do 3 things, one- grab the form data and convert them into json and then ajax call)
  2. Sever side method to consume ajax call (Controller method as I’m
    suing spring mvc.)

Any help is much appreciated.

  • 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-12T15:33:27+00:00Added an answer on June 12, 2026 at 3:33 pm

    First of all you need to perform ajax call from the JSP as below:

    $.post("${pageContext.servletContext.contextPath}/ajaxTestData",
                {
                firstName:$("#firstName").val(),
                middleNameInitial:$("#middleNameInitial").val(),
                        <other form data>
                },
                function(j)
                {
                        <j is the string you will return from the controller function.>
                });
    

    Now in the controller you need to map the ajax request as below:

     @RequestMapping(value="/ajaxTestData", method=RequestMethod.POST)
        @ResponseBody
        public String calculateTestData(@RequestParam("firstName") String firstName, @RequestParam("middleNameInitial") String middleNameInitial, HttpServletRequest request, HttpServletResponse response){
                <perform the task here and return the String result.>
    
                return "xyz";
    }
    

    I have not used the JSON input and result in this way but I think if you return the Pojo then it might converts the same in the json format automatically. Just check that.

    Hope this helps you. Cheers.

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

Sidebar

Related Questions

I have a form that i want an administrator to fill out, then click
I have a form/calculator, which posts to itself some data, this data is then
I have jquery using ajax/json to grab an elements ID and then hits: [System.Web.Services.WebMethod]
I have form and I want to send values from it with ajax to
i have a form and want to submit it with a script. i'm going
I have a form that I want to be validated before showing it initially.
I have a form which I want to be 'resusable' for a variety of
I have a form that i want to appear at the top of every
I have a form that i want to auto populate the last 2 fields
I have a Main form.I want to launch another form from it and launch

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.