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));
}