老师,您好,我用tp6框架引入wangeditor,但是无法把编辑内容的值传给后端,能帮忙分析下吗?
html:
js代码
function save(){ var data = new Object; data.content = editor.getHtml(); // if (content =='') {} $.post('/index.php/admin/article/artadd',data,function(res){ },'json'); alert(data.content); }
后端代码
public function artadd(){ //加个判断,让两个不同时执行 if (Request::isPost()) { $title = input('post.title'); $cid = input('post.cid'); $time = time(); $content = htmlspecialchars(input('post.content')); var_dump(input('content')); $status = input('post.status'); $hot = input('post.hot'); $himg = input('post.himg'); $cimg = input('post.cimg'); // $picurl = input('post.picurl'); // 获取表单上传文件 例如上传了001.jpg $file = request()->file('picurl'); // if(!empty($file)){ $savename = \think\facade\Filesystem::putFile( 'topic', $file); // }else{ // echo json_encode(['code'=>0,'msg'=>'上传图片失败']); // } $insert = Db::table('yzt_article')->insert([ 'title' => $title, 'cid' => $cid, 'content' =>$content, 'hot' => $hot, 'himg' => $himg, 'cimg' => $cimg, 'picurl' => $savename, 'status'=>$status, 'time' =>$time ]);
network中看一下请求