Controller 와 jsp 간의 Ajax를 통한 동적 통신
ajax.js
$.ajax({
url : "getResources.do", //호출할 컨트롤러
dataType : "json", //데이터 타입
type : "get", //데이터 주고받는 형식 get, post
data : {
"keyword" : $("#sKeyword").val(),
"type" : "5"
}, //전달할 데이터
success : function(getData) { //컨트롤러로부터 전달받은 데이터
$('div[id^="resourcesContents"]').load("resources.jsp",
//전달받은 데이터를 출력시킬 div와 출력될 내용의 jsp 파일
{
data_count : getData.data_count,
list_size : getData.list.length,
list : getData.list,
keyword : $("#sKeyword").val(),
time : getData.time,
//전달받을 데이터
});
},
error : function(e) { //오류 발생시
console.log(" Ajax 데이터 로드에 실패하였습니다.");
}
});
resources.jsp
데이터 개수(${param.count}건, ${param.time}초)