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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:52:51+00:00 2026-05-26T04:52:51+00:00

I am submitting a form in spring g MVC using ajax. The form is

  • 0

I am submitting a form in spring g MVC using ajax. The form is being generated dynamically. Hence I do not know the names of the request parameters submitted in the form.

In a simple form submission (not Ajax), I used to get all the parameter names and their values using the following code.

Enumeration requestParameters = request.getParameterNames();
while (requestParameters.hasMoreElements()) {
    String element = (String) requestParameters.nextElement();
    String value = request.getParameter(element);
}

But the same code does not work when I submit the form using ajax. Below is the code I am using to submit the form using ajax.

$.post("saveEntity", function() {
     alert("SUCCESS");
});

And below is my controller class method which gets called on the form submission.

@RequestMapping(method = RequestMethod.POST, value = "/saveEntity")
public @ResponseBody
void saveEntity( HttpServletRequest request) {

    Enumeration requestParameters = request.getParameterNames();

    while (requestParameters.hasMoreElements()) {
        String element = (String) requestParameters.nextElement();
        String value = request.getParameter(element);

        if (element != null && value != null) {
            logger.info("param Name : " + element
                    + " value: " + value);

        }
    }

}

Is there anything that I am doing wrong or missing something? Please help.

  • 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-26T04:52:51+00:00Added an answer on May 26, 2026 at 4:52 am

    I will start by making sure whats being sent to the server, either look at request in firebug net panel or by using fiddler and make sure data is being sent properly.

    XMLHttpRequest monitoring
    http://getfirebug.com/network

    Edit

    You are not sending any data along with your $.post.

    $.post({
           url: "saveEntity", 
           data: $('form').serialize(),
           success: function(data) {
                        alert("SUCCESS");
                    }
           });
    

    Edit 2

    Make sure $(‘form’) is actually selecting the form which you want to post.
    If not, provide correct jquery selector by specifying form id.
    Once correct form is selected use alert($('form').serialize()); to make sure its returning data in this format {elementname1: elementvalue, elementname2: elementvalue2}.
    If not then make sure elements have name attribute assigned to them.

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

Sidebar

Related Questions

I have a form I am submitting via AJAX (using prototype and the built-in
i m using asp.net mvc2 and i m submitting a form through ajax using
Hey guys, I am trying to run a proccess by submitting an AJAX form:
I have a form I am submitting using jQuery's ajaxSubmit function from the Forms
I'm using Spring 3 Portlet MVC. Validation/binding in just MVC should be the same.
With Spring MVC, it's easy to express a concept like A user is submitting
I am submitting a form to my MySQL database using PHP. I am sending
I am using spring mvc portlet for one of my applications. I have a
Ok I'm submitting a form via ajax. The result string is a bunch of
When submitting one form from view, how can i also read or have controller

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.