1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | <table id= "table" class = "table" > <thead> <tr> <th>지역</th> <th>콘텐츠명</th> <th>콘텐츠 구분</th> <th>페이지 뷰</th> </tr> </thead> <tbody> <c:forEach items= "${conList }" var = "resultList" varStatus= "status" > <tr> <td>${resultList.area}</td> <td>${resultList.name}</td> <td>${resultList.gubun}</td> <td>${resultList.cnt}</td> </tr> </c:forEach> <tr id= 'addbtn' ><td colspan= "5" ><div class = "btns" ><a href= "javascript:moreList();" class = "btn btn-primary" >더보기</a></div></td></tr> </tbody> </table> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | <script > function moreList(){ $.ajax({ url : "/admin/jsonlist" , type : "POST" , cache : false, dataType: 'json' , data : "conectType=" +conectType + "&eDate=" +eDate+ "&sDate=" +sDate+ "&codeId=" +codeId+ "&limit=" +limit, success : function (data){ //console.log(data); var content= "" ; for ( var i=0; i<data.hashMapList.length; i++){ content += "<tr>" + "<td>" +data.hashMapList[i].area+ "</td>" + "<td>" +data.hashMapList[i].name+ "</td>" + "<td>" +data.hashMapList[i].gubun+ "</td>" + "<td>" +data.hashMapList[i].cnt+ "</td>" + "</tr>" ; } content+= "<tr id='addbtn'><td colspan='5'><div class='btns'><a href='javascript:moreList();' class='btn'>더보기</a></div> </td></tr>" ; $( '#addbtn' ).remove(); //remove btn $(content).appendTo( "#table" ); }, error: function (request,status,error){ alert( "code:" +request.status+ "\n" + "message:" +request.responseText+ "\n" + "error:" +error); } }); }; </script> |
(data에 값을 확인하려면, console.log(data); 를 사용하여 크롬 개발자 모드를 통해 확인하는 것을 추천)
'JavaScript > jQuery' 카테고리의 다른 글
제이쿼리 ajax 사용시 No transport 에러 (0) | 2017.11.15 |
---|---|
ajax 비동기 통신시 return 값 변수에 저장 (0) | 2017.08.02 |
제이쿼리 timepicker (2) | 2016.05.25 |