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

时间:2014-05-20 06:21:39

标签: javascript php jquery ajax

我生成ckeditor textarea与php和ajax和ckeditor javascript文件包含在主html文件中,已经php和ajax正常工作但ckeditor没有显示在窗体中并显示简单的textarea没有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>

请帮我解决问题。

1 个答案:

答案 0 :(得分:0)

你需要在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);
    }
});