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

The Archive Base Latest Questions

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

this fnction is when clicked button, it just insert 1row to database. insert row

  • 0

this fnction is when clicked button,

it just insert 1row to database.

insert row is perfectly, but…

problem is always return ‘error alert’.

‘success alert’ is never return.

how to do.

ps. I’m sorry to my english is not good.

$(function(){
    $("[name='replyWrite']").click(function(){
        var text = $("textarea").val();
        $.ajax({
            url: "http://localhost:8080/replyWrite",
            type: "POST",
            data: "no=100&id=test&comment=this is test",
            dataType: "text",
            cache: "false",
            success: function(){
                alert("Success");
                // something to do
            },
            error: function(data, textStatus, errorThrown){
                alert("error\n" + data + ", " + textStatus + ", " + errorThrown);
            }
        });
    });
});

And replyWrite code is..

@RequestMapping(value="/replyWrite")
public String replyWrite(@RequestParam(required=true)int no
                        , @RequestParam(required=true)String id
                        , @RequestParam(required=true)String comment){
    return boardDaoJdbc.replyWrite(id, no, comment);
}



public String replyWrite(String id, int no, String comment){
    // it will be return "1"
    return Integer.toString(this.jdbcTemplate.update("INSERT INTO testz_board_reply(id, comment, linked_idx, write_date) VALUES (?, ?, ?, DATE_FORMAT(now(), '%Y-%c-%d %H:%i')) ",
                            id, comment, no));
}
  • 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-27T22:13:59+00:00Added an answer on May 27, 2026 at 10:13 pm

    If you are using ajax you need to use @ResponseBody annotation.

    so your mapping should be like this:

    @RequestMapping(value="/replyWrite", method=RequestMethod.POST)
    @ResponseBody
    public String replyWrite(@RequestParam(required=true)int no
                            , @RequestParam(required=true)String id
                            , @RequestParam(required=true)String comment){
        return boardDaoJdbc.replyWrite(id, no, comment);
    }
    

    Now on my client side:

    <script src="../scripts/jquery-latest.js"></script>
    <script type="text/javascript">
    $(document).ready(function(){
    
        $("#replyWrite").click(function () {
            var text = $("textarea").val();
            var request = "no=100&id=test&comment=this is test",
            $.post("replyWrite", request,
                       function(data) {
                        alert(data);
                       });
            });
          });
    </script>
    

    Hope it helps.

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

Sidebar

Related Questions

Typical jQuery over-use: $('button').click(function() { alert('Button clicked: ' + $(this).attr('id')); }); Which can be
I'm implementing a click button for my animation plugin, but I found a problem.
My datagrid is not going to read any value from database, but just need
I have link that calls a function when clicked: <a href=javascript:spawnMenu(this); id=link1>Test1</a> To make
I have this jQuery which works fine $(li[id^='shop_id']).click( function () { alert(I clicked on
I'd like to have a a div show only when one button is clicked
http://jqueryui.com/demos/button/#default They are very simple to use, but for some reason my buttons are
In my learning I have always learnt and understood callbacks in jQuery like this:
I'm sure this is fairly straightforward but i'm having trouble getting it to work.
So, this works: .h public slots: void addMenu(QString passedName); signals: void clicked(const QString &text);

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.