Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/79.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ajax/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 使用ckeditor、Ajax获取textarea的值_Jquery_Ajax_Ckeditor - Fatal编程技术网

Jquery 使用ckeditor、Ajax获取textarea的值

Jquery 使用ckeditor、Ajax获取textarea的值,jquery,ajax,ckeditor,Jquery,Ajax,Ckeditor,我有一个博客的表格。 它可以很好地使用ajax,无需刷新,只需序列化和提交数据。 然后我决定使用ckeditor 5,文本区域的值不提交 我的ajax脚本 $(document).ready(function(){ $("#create").click(function(event) { event.preventDefault(); var form = $("#mytest"); var for

我有一个博客的表格。 它可以很好地使用ajax,无需刷新,只需序列化和提交数据。 然后我决定使用ckeditor 5,文本区域的值不提交

我的ajax脚本

$(document).ready(function(){
    $("#create").click(function(event) {
        event.preventDefault();

        var form = $("#mytest");
        var formData = new FormData($("#mytest")[0]);
        $.ajax({
          url  : "test3.php",
          type : "POST",
          cache: false,
          contentType : false,
          processData: false,
          data: formData,
          success:function(response){
            $(".test").html(response);
          }
        });
    });
});
我的html表单

<form id="mytest" action="">
    <input type="number" name="number" value="">
    <br>
    <textarea class="editor" name="textarea"></textarea>
    <input type="submit" id="create" value="submit content">
</form>

<p class="test"></p>

CKEditor将textarea包装在自己的html标记中,因此为了获得该textarea文本,请尝试:

$('.ck-content p').text();
在较早的一个CKEditor版本中,我是这样做的

$('iframe').content().find('body').text();

给textarea一个mycontent的id

        $(document).ready(function(){
            $("#create").click(function(event) {
                event.preventDefault();

                $('#myContent').val($('.ck-content p').text());

                var form = $("#mytest");
                var formData = new FormData($("#mytest")[0]);
                $.ajax({
                  url  : "test3.php",
                  type : "POST",
                  cache: false,
                  contentType : false,
                  processData: false,
                  data: formData,
                  success:function(response){
                    $(".test").html(response);
                  }
                });
            });
        });
我就是这样做的

        $(document).ready(function(){
            $("#create").click(function(event) {
                event.preventDefault();

                $('#myContent').val($('.ck-content p').text());

                var form = $("#mytest");
                var formData = new FormData($("#mytest")[0]);
                $.ajax({
                  url  : "test3.php",
                  type : "POST",
                  cache: false,
                  contentType : false,
                  processData: false,
                  data: formData,
                  success:function(response){
                    $(".test").html(response);
                  }
                });
            });
        });