How can I get the content of CKEditor using JQuery?

If you don't hold a reference to the editor, as in Aeon's answer, you can also use the form:

var value = CKEDITOR.instances['my-editor'].getData();

If you do not save your data with a library that already encodes it by using the JavaScript encodeURIComponent method, but do it manually instead, you will have to remember to use encodeURIComponent to properly encode the data that is being sent.

So you should do below:

var value = encodeURIComponent(CKEDITOR.instances['my-editor'].getData());

For more info: https://ckeditor.com/docs/ckeditor4/latest/guide/dev_savedata.html


use the CKEditor.editor.getData() call on the instance. That is to say:

HTML

<textarea id="my-editor">
<input id="send" type="button" value="Send">

JS for CKEditor 4.0.x

$('#send').click(function() {
    var value = CKEDITOR.instances['DOM-ID-HERE'].getData()
    // send your ajax request with value
    // profit!
});

JS for CKEditor 3.6.x

var editor = CKEDITOR.editor.replace('my-editor');

$('#send').click(function() {
    var value = editor.getData();
    // send your ajax request with value
    // profit!
});