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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T14:35:12+00:00 2026-06-13T14:35:12+00:00

I have a simple JQuery function which calls my Spring MVC controller: function createDatabaseRecord()

  • 0

I have a simple JQuery function which calls my Spring MVC controller:

function createDatabaseRecord() {
    if (isFormValid()) {
        $.getJSON(
                "${pageContext.servletContext.contextPath}${databaseConfigUrl}",
                {name:$('#idName').val(),
                    databaseName:$('#idDatabaseName').val(),
                    hostName:$('#idHostName').val(),
                    username:$('#idUsername').val(),
                    password:$('#idPassword').val()},
                function (data) {
                    var html = '<span>' + data + '</span>';
                    $('#idMessage').html(html);
                }
        );
    }
}

The function is invoked when I click the button, everything is fine. The problem is that this line: $('#idMessage').html(html); does not work as expected. I have a <div> element inside the same JSP page.

<div id="idMessage">
</div>

My Spring controller method which is invoked by that function:

@RequestMapping(value = DATABASE_CONFIG_RECORD_MAPPING, method = RequestMethod.GET)
public
@ResponseBody
String createDatabaseConfiguration(@RequestParam(value = "name", required = true) String name,
                                   @RequestParam(value = "databaseName", required = true) String databaseName,
                                   @RequestParam(value = "hostName", required = true) String hostName,
                                   @RequestParam(value = "username", required = true) String username,
                                   @RequestParam(value = "password", required = true) String password) {
    try {
        DatabaseConfig config = new DatabaseConfig();
        config.setName(name);
        config.setDatabaseName(databaseName);
        config.setHostName(hostName);
        config.setUsername(username);
        config.setPassword(password);
        configService.save(config);
    } catch (Exception ex) {
        LOGGER.error("Exception while create database configuration record.", ex);
        return "Error occurred while creating database configuration record: " + ex.getMessage();
    }
    return "Database configuration record successfully created.";
}

I can see in the FireBug that response came to me:

enter image description here. This is the message: Database configuration record successfully created. I expect to be show in that <div> element, but it is not displayed. Does someone know where might be the problem? If you need some more code, please ask.

  • 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-13T14:35:14+00:00Added an answer on June 13, 2026 at 2:35 pm

    Your response is not in JSON format.

    Try this snippet in your controller:

    return Collections.singletonMap("result", "Database configuration record successfully created");
    

    And use it in javascript like this:

    var html = '<span>' + data.result + '</span>';
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written a simple jQuery.ajax function which loads a user control from the
I have a jquery mouseover event which succesfully calls a javascript function $(document).ready(function() {
I have a simple Jquery function here: function submit_selection(del,submit) { del='yes'; submit=true; var ITAMZ=new
I have this very simple jQuery function: $(.milestone-in-tree).live({ mouseenter: function() { setTimeout( $.ajax({ type:
I have pretty simple jquery code : $(document).ready(function(){ $('img.marqFl').on({ mouseenter: function() { $(this).animate({height: 300},
I have this simple function: <script type=text/javascript> //<![CDATA[ jQuery(function($){ function here(b){alert(b);} ; here(6); });
I have the following simple jquery snippet $(document).ready(function () { $.ajax({ url:myjson.json, dataType: 'json',
I have problem with passing an argument to my simple function in jQuery: When
I have a simple JQuery Stockwatcher app, which makes a JSONP request but the
I have an AJAX request (using JQuery) that calls a PHP script which does

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.