$('#[아이디]').change([함수명]=function(){
$.ajax({
url:'[주소]',
data:'변수명='+$(this).val(),
dataType:'json',
success:function(data){
data:'변수명='+$(this).val(),
dataType:'json',
success:function(data){
if(!data.data || data.data=='' || data.data.length<1) return false;
$('#[대상]').html(data.[컬럼명]);
$('#[대상]').html(data.[컬럼명]);
},
}); // $.ajax
});
SCRIPT
$('#boardDivnCd').change(changeBoardDivnCd=function(){
HTML
<select id="boardDivnCd" name="boardDivnCd">
JAVA
@RequestMapping("0001/selectGftctPupl.do")
public ModelAndView selectGftctPupl(HttpServletRequest request, HttpServletResponse response, Map<String, Object> model,0001Model 0001Model){
$('#boardDivnCd').change(changeBoardDivnCd=function(){
$.ajax({
url:'<c:url value="/0001/selectGftctPupl.do" />',
data:'boardDivnCd='+$(this).val(),
dataType:'json',
success:function(data){
data:'boardDivnCd='+$(this).val(),
dataType:'json',
success:function(data){
if(!data.data || data.data=='' || data.data.length<1) return false;
$('#content').html(data.data[0].CONTENT);
$('#content').html(data.data[0].CONTENT);
},
}); // $.ajax
});
HTML
<select id="boardDivnCd" name="boardDivnCd">
<option value="55">일반게시판</option>
<option value="56">QnA게시판</option>
<option value="57">게시판</option>
<option value="56">QnA게시판</option>
<option value="57">게시판</option>
</select>
<td id="content">내용내용내용</td>
<td id="content">내용내용내용</td>
JAVA
@RequestMapping("0001/selectGftctPupl.do")
public ModelAndView selectGftctPupl(HttpServletRequest request, HttpServletResponse response, Map<String, Object> model,0001Model 0001Model){
try{
List<DataMap> data=0001Service.selectGftctPupl(0001Model); // 데이터 조회
if(data==null || data.size()==0) return new ModelAndView("jsonView",model);
if(data==null || data.size()==0) return new ModelAndView("jsonView",model);
model.put("data",data);
}catch (Exception e){}
return new ModelAndView("jsonView",model);
}
출처 - http://blog.nachal.com/464
'Development > jQuery' 카테고리의 다른 글
jquery - 메소드 정리 (0) | 2012.11.01 |
---|---|
jQuery - textarea byte check (0) | 2012.07.24 |
jquery ajax pagination 예제 (0) | 2012.06.16 |
jQuery UI CSS Framework 3 - ibm (0) | 2012.06.09 |
jQuery UI CSS Framework 2 (0) | 2012.06.09 |