2014-05-20 30 views
0

我生成ckeditor textarea與PHP和Ajax和ckeditor JavaScript文件包括在主要的HTML文件中,已經PHP和Ajax工作正常,但ckeditor不顯示在窗體和顯示簡單的textarea沒有eceditor工具欄。JavaScript文件不適用於與AJAX和PHP生成ckeditor

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> 

請幫我解決了問題。

+0

包含您的Ajax響應什麼? –

+0

ajax response contains textarea:echo''; – user3652721

回答

0

需要綁定在阿賈克斯的成功處理程序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); 
    } 
}); 
+0

感謝您的回覆,但不起作用! – user3652721