JS
Ajax로 호출해서 받은 결과 값을 JSTL로 뿌려주기
곰탁
2021. 12. 17. 15:02
결론부터 말하면 안됨.
순서상의 문제로 그럴 수 없다고 함.
렌더링 순서가 JAVA>>JSTL>>HTML>>JavaScript 이기 때문에 불가능하다.
되게 하는 방법은 다른 template를 만든다음 그 걸 씌우는 방법.
function ajax_Callback(data){
var noticeList = data;
var dataTemplate = $('#template-contracted-list').html();
var rows = "";
var colorByType = '';
var sell_buy_recog_cd = '';
if (noticeList.length > 0) {
$(noticeList).each(function () {
rows += dataTemplate
.replace(/{seqNo}/g, this.seqNo)
.replace(/{title}/g, this.title)
.replace(/{regDt}/g, this.regDt)
});
$('tbody').html(rows);
} else {
$('tbody').html($('#template-list-empty').html());
}
}
<Script id="template-contracted-list" type="text/template">
<tr>
<td>{seqNo}</td>
<td>{title}</td>
<td>{regDt}</td>
</tr>
</Script>
아니면 뭐 서버 호출해야지...