這篇文章給大家介紹怎樣將ajax請求返回的Json格式數(shù)據(jù)循環(huán)輸出成table形式,內(nèi)容非常詳細(xì),感興趣的小伙伴們可以參考借鑒,希望對大家能有所幫助。
首先,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>
后臺(tái)處理請求,返回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)建時(shí)間</th><th>操作</th></tr>
</table>
效果如圖
OK
關(guān)于怎樣將ajax請求返回的Json格式數(shù)據(jù)循環(huán)輸出成table形式就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,可以學(xué)到更多知識(shí)。如果覺得文章不錯(cuò),可以把它分享出去讓更多的人看到。
文章標(biāo)題:怎樣將ajax請求返回的Json格式數(shù)據(jù)循環(huán)輸出成table形式-創(chuàng)新互聯(lián)
當(dāng)前路徑:http://aaarwkj.com/article6/dpgcig.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供做網(wǎng)站、小程序開發(fā)、網(wǎng)站策劃、網(wǎng)站設(shè)計(jì)、品牌網(wǎng)站設(shè)計(jì)、電子商務(wù)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容