52,797
社区成员
发帖
与我相关
我的任务
分享
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script src="http://cdn.bootcss.com/jquery/1.8.3/jquery.min.js"></script>
</head>
<body>
<div class="renshu"></div>
<div class="ren"><ul></ul></div>
<script>
$.ajax({
url: "1.php",
type: 'GET',
success: function(data) {
var value = data;var count = parseInt(value[0]);$(".renshu").append(count);
var list = $(".ren ul");
for(var i=1;i<=count;i++){
list.append("<li>"+value[i]+"</li>");
}
},
beforeSend: function(xhr) {
xhr.setRequestHeader("Cache-Control", "no-cache");
},
async: true,
});
</script>
</body>
</html>
$(function() {
var comments = $("#comments");
$.getJSON("ajax.php", function(json) {
$.each(json, function(index, array) {
var txt = "<p style='word-wrap:break-word' ><strong>" + array["id"] + "楼</strong>:" + array["comment"] + "<br><span> -><span>" + array["addtime"] + "</span></p>";
comments.append(txt);
});
});