ajax 가 요청 한 JSon 형식 데 이 터 를 table 형식 으로 순환 출력 하 는 방법

우선,Ajax 요청 데이터,(Jquery 의 Ajax 사용)
 
<script>
$(function(){
$('#test').click(function(){
$.ajax({
url:'__APP__/Article/jsonTest',
type:'post',
success:function(data){
var item;
$.each(data,function(i,result){
item = "<tr><td>"+result['num']+"</td><td>"+result['title']+"</td><td>"+result['credate']+"</td><td> </td></tr>";
$('.table').append(item);
});
}
})
})
});
</script>
배경 처리 요청,JSon 형식 데이터 되 돌려 주기(Thinkphp 로 되 돌려 주기)
 
$list = $File->group('num')->order('id desc')->limit($Page->firstRow.','.$Page->listRows)->select();
$this->ajaxReturn($list,'JSON');
html 부분
 
<table class="table table-striped table-bordered table-condensed">
<tr><th> </th><th> </th><th> </th><th> </th></tr>
</table>
효 과 는 그림 OK

좋은 웹페이지 즐겨찾기