2014-08-31 86 views
2

我已将CKEDITOR并入我的网站。我希望它从数据库加载内容,以便它可以被编辑。我可以使用ajax轻松地将数据从编辑器保存到数据库。然而,当编辑首创负载我在铬控制台得到一个错误:将数据库内容加载到ckeditor的textarea中

Uncaught SyntaxError: Unexpected token ILLEGAL

这点我在我的jQuery代码的地方:

enter image description here

contentEditor.append('<div class="content-top-container"><div class="course-name"><div class="section-title">Title: <?php echo $this->section_title; ?></div><img id="close-<?=$this->c_id;?><?php echo $this->section_num; ?>" class="close-editor" src="../skins/blues/images/red-ex.png" title="Close" /></div></div><br /><textarea class="editor-area" id="<?php echo $this->c_id; ?>-<?php echo $this->section_num; ?>-editor" name="<?php echo $this->section_num; ?>-editor">'+innerTextArea+'</textarea>'); 
    CKEDITOR.replace('<?php echo $this->c_id; ?>-<?php echo $this->section_num; ?>-editor', { 
     toolbar : 'Full', 
     width : "1020px" 
    }); 

数据被存储为数据库中的HTML。我相信正在发生的事情是,从数据库返回的字符串会很长,并且Javascript会引发语法错误。我怎样才能解决这个问题?我几乎没有CKEditor的经验......先谢谢了!

回答

1

只是编码字符串正确

var innerTextArea = <?php echo json_encode($inner->TextArea) ?>; 
+0

谢谢@Musa - 答案工作。干杯 – massimorai 2014-09-01 11:48:46