首先,Ajax請求數(shù)據(jù),(用的是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格式數(shù)據(jù)(用的是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>創(chuàng)建時間/th>th>操作/th>/tr>
/table>
效果如圖
OK
您可能感興趣的文章:- jQuery使用ajax方法解析返回的json數(shù)據(jù)功能示例
- jquery的ajax異步請求接收返回json數(shù)據(jù)實例
- 基于jQuery的AJAX和JSON實現(xiàn)純html數(shù)據(jù)模板
- JQuery處理json與ajax返回JSON實例代碼
- jQuery通過Ajax返回JSON數(shù)據(jù)
- jQuery中ajax請求后臺返回json數(shù)據(jù)并渲染HTML的方法