test.html ( getJSON() 이용 )
페이지 정보
본문
<!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>
<br>
</center>
<script th:inline="javascript">
var bno = 20; // t_board에서 존재하는 boardIdx값 입력
$.getJSON("/replies/all/"+bno,
function(data){
$("#total_conunt").text(data.length); //리스트 갯수
}
);
</script>
</div>
</body>
</html>
<!--
==== 설명 ====
@RestController의 경우 객체를 JSON 방식으로 전달하기 때문에 jQuery를 이용해서 호출할 때는 getJSON()을 이용합니다.
console에서 data.length가 출력되는 것을 확인할 수 있다.
-->
- 이전글BoardController 24.06.13
- 다음글test.html ( 리스트 출력 ) 24.06.13
댓글목록
등록된 댓글이 없습니다.