test.html ( 리스트 출력 )
페이지 정보
![profile_image](https://dancepkt.cafe24.com/data/member_image/ad/admin.gif?1630310007)
본문
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
layout:decorate="~{include/layout.html}">
<body>
<div layout:fragment="content">
<br>
<center>
<h1>AJAX TEST</h1>
Total : <span id="total_conunt"></span>
<!-- 댓글 목록 출력 영역 -->
<table id="replies" width=700 border=1></table>
</center>
<script th:inline="javascript">
var bno = 20; // t_board에서 존재하는 boardIdx값 입력
getAllList(); //호출
// 글 목록
function getAllList() { // 리스트 출력 확인후 목록 갱신시 함수 호출로 처리
$.getJSON("/replies/all/"+bno,
function(data){
$("#total_conunt").text(data.length); //리스트 갯수
var str="";
$(data).each(
function(){
str += "<tr>"
+ "<td>"+this.rno+"</td>"
+ "<td>"+this.bno+"</td>"
+ "<td>"+this.replyer+"</td>"
+ "<td>"+this.replytext+"</td>"
+ "<td data-rno='"+this.rno+"' class='replyLi'><button>mode</button></td>"
+ "</tr>"
}
);
$("#replies").html(str);
}
);
}
</script>
</div>
</body>
</html>
<!--
==== 설명 ====
@RestController의 경우 객체를 JSON 방식으로 전달하기 때문에 jQuery를 이용해서 호출할 때는 getJSON()을 이용합니다.
console에서 data.length가 출력되는 것을 확인할 수 있다.
-->
- 이전글test.html ( getJSON() 이용 ) 24.06.13
- 다음글test.html ( 글쓰기 ) 24.06.13
댓글목록
등록된 댓글이 없습니다.