HTML:
getJSON* { margin:0; padding:0;}
body { font-size:12px;}
.comment { margin-top:10px; padding:10px; border:1px solid #ccc;background:#DDD;}
.comment h6 { font-weight:700; font-size:14px;}
.para { margin-top:5px; text-indent:2em;background:#DDD;}
//
$(function(){
$('#send').click(function() {
$.getJSON('test.json',
function(data) {
$('#resText').empty();
var html = '';
$.each( data ,
function(commentIndex, comment) {
html += '
})
$('#resText').html(html);
})
})
})
//]]>
test.json :
[{
"username": "张三",
"content": "沙发."
},
{
"username": "李四",
"content": "板凳."
},
{
"username": "王五",
"content": "地板."
}]
来源:https://www.cnblogs.com/ybingbing_1213/p/3968071.html
' + comment['username'] + ':
' + comment['content'] + '