简体   繁体   English

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

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

I generate ckeditor textarea with php and ajax and ckeditor javascript files include in main html file, already php and ajax work correctly but ckeditor doesn't display in form and display simple textarea without eceditor toolbars. 我用php和ajax生成了ckeditor textarea,并且ckeditor javascript文件包含在主html文件中,已经php和ajax可以正常工作,但是ckeditor无法以表单形式显示,并且没有eceditor工具栏也不会显示简单的textarea。

ajax code: 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 code: php代码:

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

html code: 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>

Please help me for resolve problem. 请帮助我解决问题。

you need to bind ckeditor in the success handler of ajax, 您需要将ckeditor绑定到ajax的成功处理程序中,

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM