Javascript文件不适用于使用ajax和php生成的ckeditor

javascript file doesn't work for ckeditor generated with ajax and php

本文关键字:php ckeditor ajax 不适用 文件 适用于 Javascript      更新时间:2023-09-26

我生成ckeditor文本区与php和ajax和ckeditor javascript文件包括在主html文件,已经php和ajax工作正常,但ckeditor不显示形式和显示简单的文本区没有eceditor工具栏。

ajax代码:

    jQuery.ajax({
    type: "POST",
    url: "reg_arz_ajax2.php",
    data: "book="+book_arzyabi,
    dataType : "html",
    success: function(response){
        $('#resp').html(response);
    },
    error:function (xhr, ajaxOptions, thrownError){
        //On error, we alert user
        alert(thrownError);
    }
});
$( "#dialog-form" ).dialog( "open");
});
php代码:

    echo '<textarea class="ckeditor" cols="80" id="fname" name="fname" rows="10" >test</textarea>';
html代码:

  <html>
 <head>
 <script type="text/javascript" src="../include/ckeditor/ckeditor.js"></script>
 <script type="text/javascript" src="../include/ckeditor/sample.js" ></script>
 </head>
 <body>
 <form>
 <fieldset>
 <label for="name">Name</label>
 <div id="resp" ></div>
 </fieldset>
 </form>
 </body>
 </html>

请帮我解决这个问题

您需要在ajax的成功处理程序中绑定ckeditor

jQuery.ajax({
    type: "POST",
    url: "reg_arz_ajax2.php",
    data: "book=" + book_arzyabi,
    dataType: "html",
    success: function (response) {
        $('#resp').html(response);
        $(".ckeditor").ckeditor();
    },
    error: function (xhr, ajaxOptions, thrownError) {
        //On error, we alert user
        alert(thrownError);
    }
});