论坛盖楼回复样式
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>论坛</title>
<style media="screen">
.commentbox{
border: 1px solid #ccc;
padding: 10px;
margin: 2px;
}
</style>
</head>
<body>
<div class="commentbo">
盖楼!!盖楼!!盖楼
<div class="commentbox">
盖楼!!盖楼!!盖楼
<div class="commentbox">
盖楼!!盖楼!!盖楼
</div>
</div>
</body>
</html>
MongoDB数据库,json格式数据。通过AJAX实现获取和添加数据。
<script>
//查询评论
function getDiscuss(){
$.ajax({
url:'http://192.168.182.129:3000/admin/getDiscuss',
data:{gid:goodsID},
dataType:'json', type:'post',
success:function(data){
var c=data; var a='<div class="commentsinfo">';
var b='<p class="theauthor">';
var h='</p ><span class="commentsnumber">';
var d='</span><p>';
var e='</p ></div>';
var g='<div class="comments">';
var str=''; for (var i = 0; i < c.length; i++) {
var xstr=''; var x=c[i]._contents;
}
}
})
}
</script>
发表评论
<script>
function doDiscuss(){
var con=$('#sendM').val();
$.ajax({
url:'http://192.168.20.222:3000/admin/doDiscuss' ,
data:{content:con, gid:goodsID},
dataType:'json', type:'post',
success:function(data){
if(data.result =='yes'){
$('#sendM').val(''); getDiscuss();
alter('发表成功')
}else if(data.result=='noLogin'){
$('#hiddenLogin').click();
}
}
})
}
</script>
//获取所有评论
//javascript序列化:serialize是一个json对象
//获取评论
export.getDiscuss=function(req,res,next){
goodsModel.getDiscuss(req.body.gid,'discuss',function(result){
if(result !='error'){
res.json(result);
}else{
res.json('error');
}
})
}