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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T11:51:37+00:00 2026-06-04T11:51:37+00:00

I am working on a project adding some Ajax to a Spring-MVC project. I

  • 0

I am working on a project adding some Ajax to a Spring-MVC project. I removed the tags

<form:errors path="fieldName"/>

That would insert the error the JSP, now I am trying to make some Ajax code to display the errors on the page. can anyone should me how to updated the following code to display the error messages and NOT the errors?

success: function(response)
          {
          // we have the response 
            $('#error').hide('fast');   
            if(response.status == "SUCCESS")
            {
                $('#error').hide('fast');  
                alert("Thanks for submitting.  We will get back to you as soon as possible.\n\n" + response.result);
                $('#error').hide('slow');

            }else
            {
              errorInfo = "";
              for( i = 0 ; i < response.result.length ; i++){
                  errorInfo += "<br>" + (i + 1) +". " + response.result[i].code;
              }
              $('#error').html("Please correct following errors: " + errorInfo);
              $('#info').hide('slow');
              $('#error').show('slow');
              $('#input').show('slow');
          }       
        },  
        error: function(e){  
          alert('Error: ' + e);  
        }  
      });  

The above code works to display the errors but not the error messages

below is my java code:

    @RequestMapping(value = "/ajax.html", method = RequestMethod.POST)
    public @ResponseBody
    JsonResponse addMessage(@Valid
            @ModelAttribute(value = "memberrequest") MemberRequest memberrequest,
            BindingResult result) {

            JsonResponse res = new JsonResponse();


        if (!result.hasErrors()) {
            res.setStatus("SUCCESS");

            // Setting data over to RT

            String Ticket = zzz.sentWebRequest(memberrequest);

            /*
             * Setting out the ticket number to be displayed to user
             */

            Map<String, Object> model = new HashMap<String, Object>();
            Ticket t = new Ticket();
            t.setTicketDetails(Ticket);

            model.put("ticket", t);

            res.setResult(Ticket);
        } else {
            res.setStatus("FAIL");
            res.setResult(result.getAllErrors());
        }

        return res;
    }
}

JSON Class:

public class JsonResponse { private String status = null; private
Object result = null;

public String getStatus() { return status; }

public void setStatus(String status) { this.status = status; }

public Object getResult() { return result; }

public void setResult(Object result) { this.result = result; }

}

  • 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-04T11:51:39+00:00Added an answer on June 4, 2026 at 11:51 am

    Try response.result[i].defaultMessage instead of response.result[i].code.

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

Sidebar

Related Questions

I'm working on project that lets users choose some scientific authors and columnists and
The project that I've been working on involves porting some old code. Right now
My GWT Project was working fine but today, after some changes and adding new
I have an ASP.NET WebForms application that I'm adding some ASP.NET MVC to. I
I am working on a project that at it's core involves adding text to
We are currently working on a small project, we are updating and adding some
I am working on a MVC project that is supposed to have one page
I'm working on a project that has to connect to some ancient webservices that
I am adding a few new features to a small project i'm working on
I am working a project with many NUnit tests, that were already written long

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.