search

Home  >  Q&A  >  body text

wangeditor cannot pass value to backend

Hello, teacher, I use the tp6 framework to introduce wangeditor, but I cannot pass the value of the editing content to the backend. Can you help analyze it?

html:

<form class="form-horizontal" role="form" enctype="multipart/form-data" method="post" action="/index.php /admin/article/artadd"> <div class="form-group"> <label for="title" class="col-sm-2 control-label">title</label> < ;div class="col-sm-10"> <input type="text" class="form-control" id="title" name="title" placeholder="Please enter a title" > </ div> </div>

<div id="editor—wrapper" name="content"> <div id="toolbar-container" ><!-- Toolbar- -></div> <div id="editor-container" > <!-- Editor--></div> </div> <div class="col-md -2 col-md-offset-9"> <button type="submit" class="btn btn-default" style="float: right;" onclick="save();">Save</ button> </div> </form>

##js code

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); }

Backend code

public function artadd(){ //Add a judgment so that the two are not executed at the same time if (Request::isPost()) { $title = input('post.title');         $cid = input('post.cid');           $time = time();             $content = htmlspecialchars(input('post.content')); )); $status = input('post.status'); $hot = input('post.hot'); $himg = input('post.himg'); $cimg = input('post.cimg') ;                                                                                                                                                                                                          $picurl = input('post.picurl'); $file)){ $savename = \think\facade\Filesystem::putFile( 'topic', $file); // }else{ echo json_encode(['code'=>0,'msg'=> ;'Unable to upload image']); ' =>$content, ' 'hot' => $hot, ' 'himg' => $himg, 'cimg' => $cimg, ' 'picurl' => $savename, ' 'status'=>$ status,           'time' =>$time                                                                                                                                                                                    
P粉021180371P粉021180371736 days ago857

reply all(1)I'll reply

  • autoload

    autoload2022-11-25 09:20:21

    Look at the request in the network

    reply
    0
  • Cancelreply