码迷,mamicode.com
首页 > Web开发 > 详细

ajax json to table

时间:2015-05-06 10:40:36      阅读:246      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!