이 기능을 클릭하면 버튼이 클릭됩니다.jquery ajax with spring mvc3 사용 방법
그냥 데이터베이스에 삽입하십시오.
삽입 행은
문제는 항상 '오류 경고'를 반환한다 ... 완벽하지만.
'성공 알림'은 반환되지 않습니다.
하는 방법.
ps. 나는 나의 영어에 유감 스럽다 좋지 않다.
$(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);
}
});
});
});
그리고 replyWrite 코드입니다 ..
@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));
}
정말 고마워요 !!! – lng0415