如何將ajax請(qǐng)求返回的Json格式數(shù)據(jù)循環(huán)輸出成table形式
來(lái)源:懂視網(wǎng)
責(zé)編:小采
時(shí)間:2020-11-27 22:52:15
如何將ajax請(qǐng)求返回的Json格式數(shù)據(jù)循環(huán)輸出成table形式
如何將ajax請(qǐng)求返回的Json格式數(shù)據(jù)循環(huán)輸出成table形式:首先,Ajax請(qǐng)求數(shù)據(jù),(用的是Jquery的Ajax) 代碼如下:<script> $(function(){ $('#test').click(function(){ $.ajax({ url:'__APP__/Article/jsonTest', type:'post', success:function(data){
導(dǎo)讀如何將ajax請(qǐng)求返回的Json格式數(shù)據(jù)循環(huán)輸出成table形式:首先,Ajax請(qǐng)求數(shù)據(jù),(用的是Jquery的Ajax) 代碼如下:<script> $(function(){ $('#test').click(function(){ $.ajax({ url:'__APP__/Article/jsonTest', type:'post', success:function(data){

首先,Ajax請(qǐng)求數(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)處理請(qǐng)求,返回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>編號(hào)</th><th>名稱</th><th>創(chuàng)建時(shí)間</th><th>操作</th></tr>
</table>
效果如圖
OK
聲明:本網(wǎng)頁(yè)內(nèi)容旨在傳播知識(shí),若有侵權(quán)等問(wèn)題請(qǐng)及時(shí)與本網(wǎng)聯(lián)系,我們將在第一時(shí)間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com
如何將ajax請(qǐng)求返回的Json格式數(shù)據(jù)循環(huán)輸出成table形式
如何將ajax請(qǐng)求返回的Json格式數(shù)據(jù)循環(huán)輸出成table形式:首先,Ajax請(qǐng)求數(shù)據(jù),(用的是Jquery的Ajax) 代碼如下:<script> $(function(){ $('#test').click(function(){ $.ajax({ url:'__APP__/Article/jsonTest', type:'post', success:function(data){