반응형
댓글달기
script 부분
function refreshComment(){
var qnaNo = ${resultList.qnaContentVo.qna_no};
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function(){
if(xmlhttp.readyState == 4 && xmlhttp.status == 200){
var obj = JSON.parse(xmlhttp.responseText);
var commentListBox = document.getElementById("comment_list_box");
var childCount = commentListBox.childNodes.length;
for(var i = 0 ; i < childCount ; i++){
commentListBox.childNodes[0].remove();
}
for(commentData of obj){
var rowBox = document.createElement("div");
rowBox.setAttribute("class","row");
var contentBox = document.createElement("div");
contentBox.setAttribute("class","col-9 alert alert-primary");
contentBox.innerText = commentData.qnaCommentVo.qna_comment_text;
var nickBox = document.createElement("div");
nickBox.setAttribute("class","col-1 alert alert-success");
nickBox.innerText = commentData.ccrMemberVo.member_nickname;
var dateBox = document.createElement("div");
dateBox.setAttribute("class","col-2 alert alert-danger");
var d = new Date(commentData.qnaCommentVo.qna_comment_date);
var strDate = d.getFullYear() + "-" + (d.getMonth() + 1) + "-" + d.getDate();
dateBox.innerText = strDate;
rowBox.append(contentBox);
rowBox.append(nickBox);
rowBox.append(dateBox);
commentListBox.append(rowBox);
}
}
};
xmlhttp.open("get","${pageContext.request.contextPath}/manager/get_qna_comment_list.do?qna_no=" + qnaNo);
xmlhttp.send();
}
반응형
'JSP' 카테고리의 다른 글
[JSTL] list size jsp로 출력하기 (0) | 2021.08.28 |
---|---|
ajax HashMap 넘기기 (0) | 2021.02.02 |
${page_num +1} (0) | 2021.01.26 |
JSTL 문자열 비교하고 싶을 때 (0) | 2021.01.15 |
[JSP&Servlet] Scope - Page, Request, Session, Application (0) | 2020.12.04 |