Reputation: 345
I've incorporated CKEDITOR to my website. I want it to load the content from the database so it can be edited. I can save data with ease from the editor to the database, using ajax. however when the editor firsts loads I get an error in my chrome console:
Uncaught SyntaxError: Unexpected token ILLEGAL
It points me to a place in my jQuery code:
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"
});
Data is being stored as HTML in the database. What I believe is happening is that the string that is coming back from the database is to long and Javascript is throwing a syntax error. How can I fix this? I have little experience with CKEditor... thanks in advance!
Upvotes: 2
Views: 1048
Reputation: 97672
Just encode the string properly
var innerTextArea = <?php echo json_encode($inner->TextArea) ?>;
Upvotes: 2