// 전체조회
function showNotice() {
var settings = {
"url": "http://localhost:8080/api/managers/notices/check",
"method": "GET",
"timeout": 0
};
$
.ajax(settings)
.done(function (response) {
console.log(response);
let rows = response.data
for (let i = 0; i < rows.length; i++) {
let noticeId = rows[i]['id']
let number = i + 1
let title = rows[i]['title']
let createdDate = rows[i]['createdDate']
let temp_html = ` <tr>
<td>${number}</td>
<td><a href ="contactDe-Notice.html?${noticeId}">${title}</td>
<th>${createdDate}</th>
</tr>`
$('#noticeList').append(temp_html)
}
});
}
상세페이지로 이동
<td><a href ="contactDe-Notice.html?${noticeId}">${title}</td>
$(document).ready(function(res){ //페이지에 가져온 값을 보여줄때
var para = document.location.href.split("?"); //href 는 현 도큐먼트를 말함. ? 쪼개면 /{ }값을 받음
console.log(para[1])
var settings = {
"url": "
[http://localhost:8080/t-exercise/selectboard/](http://localhost:8080/t-exercise/selectboard/)
"+para[1],// 이렇게 쓰면 @Pathvariable값을 받음
"method": "GET",
"timeout": 0,
};
형식 예
URL?keyword=" + $('#keywordInput').val(),
// 검색창 조회
function noticeSearch() {
var settings = {
"url": "http://localhost:8080/api/managers/notices/check/keywords?keyword=" + $('#keywordInput').val(),
"method": "GET",
"timeout": 0
};
$
.ajax(settings)
.done(function (response) {
$('#noticeList').empty()
console.log(response);
let rows = response.data;
for (let i = 0; i < rows.length; i++) {
let number = i + 1
let title = rows[i]['title']
let createdDate = rows[i]['createdDate']
let temp_html = ` <tr>
<td>${number}</td>
<td>${title}</td>
<th>${createdDate}</th>
</tr>`
$('#noticeList').append(temp_html)
}
alert("조회 성공");
});
}
$('#t_exePosting').on("click", "button[name='enrollComment']", function()