首页 > Web开发 > 详细

ajax json to table

时间:2015-05-06 10:39:53      阅读:235      评论:0      收藏:0      [点我收藏+]

案例一

 

http://jsfiddle.net/neerajkumarsingh/tqyn3/

 

<table id="records_table" border=‘1‘>
<tr>
<th>Rank</th>
<th>Content</th>
<th>UID</th>
</tr>
</table>

 

var jsonData = ‘[{"rank":"9","content":"Alon","UID":"5"},{"rank":"6","content":"Tala","UID":"6"}]‘;

$.ajax({
url: ‘/echo/json/‘,
type: ‘POST‘,
data: {
json: jsonData
},
success: function (response) {
var trHTML = ‘‘;
$.each(response, function (i, item) {
trHTML += ‘<tr><td>‘ + item.rank + ‘</td><td>‘ + item.content + ‘</td><td>‘ + item.UID + ‘</td></tr>‘;
});
$(‘#records_table‘).append(trHTML);
}
});

ajax json to table

原文:http://www.cnblogs.com/jeremyjs/p/4481028.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!