Php 在ajax页面中附加编辑器

Php 在ajax页面中附加编辑器,php,ajax,ckeditor,Php,Ajax,Ckeditor,我尝试将ckeditor附加到php页面中的textarea,ajax在html页面中调用它,但是ckeditor没有出现在textarea中。任何人都知道,为什么它没有发生,它只是让我感到奇怪 TRY1.HTML 函数加载() { if(window.XMLHttpRequest) {//IE7+、Firefox、Chrome、Opera、Safari的代码 xmlhttp=新的XMLHttpRequest(); } 其他的 {//IE6、IE5的代码 xmlhttp=新的ActiveXO

我尝试将ckeditor附加到php页面中的textarea,ajax在html页面中调用它,但是ckeditor没有出现在textarea中。任何人都知道,为什么它没有发生,它只是让我感到奇怪

TRY1.HTML


函数加载()
{
if(window.XMLHttpRequest)
{//IE7+、Firefox、Chrome、Opera、Safari的代码
xmlhttp=新的XMLHttpRequest();
}
其他的
{//IE6、IE5的代码
xmlhttp=新的ActiveXObject(“Microsoft.xmlhttp”);
}
xmlhttp.onreadystatechange=函数()
{
if(xmlhttp.readyState==4&&xmlhttp.status==200)
{
document.getElementById(“div_content”).innerHTML=xmlhttp.responseText;
}
}
open(“GET”、“try2.php?”,true);
xmlhttp.send();
}
TRY2.PHP

      <textarea id="txt1"> </textarea>

这是因为绑定编辑器的文本区域在页面的初始加载时不存在,因此无法绑定。 您应该在ajax调用的成功回调中绑定它。 成功的话,你应该用ckeditor绑定textarea,它会工作的

if (xmlhttp.readyState==4 && xmlhttp.status==200) {
    document.getElementById("div_content").innerHTML=xmlhttp.responseText;
    document.getElementById("txt1").ckEditor();
    //or whatever the exact code you do for ckEditor
}

文本区域是否由于ajax调用响应而出现在页面上?是的,初始页面是home.html,中间部分使用ajax包含一个空白div。我正在该div中加载一个名为add_content.php的php页面。文本区域位于该php页面中。检查我的答案,我已经在其中发布了一些代码,它很可能在您的情况下起作用。请让我知道它是否起作用。Thankz现在您可以告诉我如何在ajax的成功回调中绑定该文本区域,这对我非常有帮助。为我发布您的代码,只需编辑问题并在其中添加代码。函数load(){if(window.XMLHttpRequest){xmlhttp=new-XMLHttpRequest()}else{xmlhttp=new-ActiveXObject(“Microsoft.xmlhttp”);}xmlhttp.onreadystatechange=function(){if(xmlhttp.readyState==4&&xmlhttp.status==200){document.getElementById(“div_-content”).innerHTML=xmlhttp.responseText;}xmlhttp.open(“GET”,“try2.php?”,true);xmlhttp.send();}第一个是我的主页,在那里,按钮try2.php上的CLIK事件将出现,这是第二个
if (xmlhttp.readyState==4 && xmlhttp.status==200) {
    document.getElementById("div_content").innerHTML=xmlhttp.responseText;
    document.getElementById("txt1").ckEditor();
    //or whatever the exact code you do for ckEditor
}