首先在控制器里面:
把记录添加到数据库里
public function replytext(){
$content = I('post.content');
$data['content'] = $content;
$ret = M('mp_reply_text')->add($data);
if(isset($ret)){
$mp = getCurrentMp();
$arr['mpid'] = $mp['id'];
$arr['reply_id'] = $ret;
$keyword = I('post.keyword');
$arr['keyword'] = $keyword;
$arr['type'] = 'text';
$ret = M('mp_rule')->add($arr);
$this->ajaxReturn(array('msg'=>'添加成功'));
}else{
$this->ajaxReturn(array('msg'=>'添加失败'));
}
}
视图前台:
layui.use('form', function(){
var form = layui.form
form.on('submit(SBT)', function(data){
var load = layer.load();
$.post("{:U('addtext')}",data.field,function (res) {
layer.close(load);
layer.msg(res.msg,{time:1000},function () {
})
})
return false;
});
});
最后要在引入文件中修改:
case 'text':
$reply = M('mp_reply_text')->find($reply_id);
if($reply){
$reply_text = $reply['content'];
}else{
$reply_text = "出错啦";
}
return ResponsePassive::text($request['fromusername'], $request['tousername'],$reply_text);
break;