How to add data to CKEditor using JQuery

Viewed 83695

Everytime a page loads I need to load text into the CK Editor using JQuery, in order to get data from CK Editor I use

var editor_data = CKEDITOR.instances['editor1'].getData();

now is there a similar function I could use to put the data back into the editor?

I'm using ajax to set the data like this

$.ajax({
  type: "POST",
  url: "/inc/ajax/basic.php?menu_id="+menu_id+"&info=3",
  success: function(msg){

    CKEDITOR.instances['editor1'].setData(msg);
  }
});

What am I doing wrong

7 Answers

Try this:

CKEDITOR.instances['editor1'].setData(html)

Where 'html' is a string containing content to edit.

Related