<script>
$.ajax({
url:略,
success:function(res){
var html=""
res.article.forEach(function(e){
html+="<dt>"+e.title+"</dt>"
html+="<dd>"+e.content
if(e.images)e.images.forEach(ee){
html+="<img src='"+ee+"'/>"
}
html+="</dd>"
})
$("#output").append(html)
}
})
</script>
$(function(){var comments = $("#comments")
$.getJSON("server.php",function(json){
$.each(json,function(index,array){
var txt = "<p><strong>"+array["user"]+"</strong>:"+array["comment"]+"<span>"
+array["addtime"]+"</span></p>"
comments.append(txt)
})
})
$("#add").click(function(){
var user = $("#user").val()
var txt = $("#txt").val()
$.ajax({
type:'POST',
url:"comment.php",
data:"user="+user+"&txt="+txt,
success:function(msg){
if(msg==1){
var str = "<p><strong>"+user+"</strong>:"+txt+"<span>刚刚</span></p>"
comments.append(str)
$("#message").show().html("发表成功!").fadeOut(1000)
$("#txt").attr("value","")
}else{
$("#message").show().html(msg).fadeOut(2000)
}
}
})
})
})
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)