본문 바로가기

개발하자/ajax&json

회원리스트 클릭시 순서있는 리스트로 db id뿌리기

<%@ page language="java" contentType="text/html; charset=EUC-KR"
    pageEncoding="EUC-KR"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
<title>Insert title here</title>
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
<script type="text/javascript">
$(document).ready(function(){
 $("#memberlist").click(memberListFunc);
});

function memberListFunc(){
 $.ajax({
  url:"member/listMember.do",
  dataType:"json",
  success:function(data){
   //alert(data.list[0].id);
   $("<ol/>",{
    id:"olTag"
   }).appendTo("#memberlistCon");
   $.each(data.list,function(index,member){
    $("<li/>",{
     id:"olTag",
     html:member.id
    }).appendTo("#olTag");
   });
  }
  
 });
}
</script>

</head>
<body>
 welcome to SEOUL IT Education Center~!!!<br/>
 <a href="member/loginForm.html">로그인</a>
 <a href="#" id="memberlist">회원리스트</a>
 <div id="memberlistCon"></div>
</body>
</html>