test.html ( 리스트 출력 ) > SPRINGBOOT

본문 바로가기
사이트 내 전체검색

SPRINGBOOT

test.html ( 리스트 출력 )

페이지 정보

profile_image
작성자 관리자
댓글 0건 조회 34회 작성일 24-06-13 10:19

본문

<!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가 출력되는 것을 확인할 수 있다.

-->

댓글목록

등록된 댓글이 없습니다.

회원로그인

회원가입

사이트 정보

공지사항
자유게시판
질문답변
1:1문의

 

별명 : 터푸가위
주소 : 부산시 동래구 명장로20번길 90
대표 : 박규태
메일 : dancepkt@******.com

접속자집계

오늘
185
어제
285
최대
10,760
전체
277,791
Copyright © dancePKT . All rights reserved.