How to add data to CKEditor using JQuery

后端 未结 7 1967
无人及你
无人及你 2020-12-07 20:33

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[\'         


        
7条回答
  •  北海茫月
    2020-12-07 21:29

    var editor = CKEDITOR.instances.help_ldesc;         
    editor.setData(''); 
    $.ajax({
    url: urlstr, // Url to which the request is send
    type: "POST",             // Type of request to be send, called as method
    data:{action:"ex_form"}, // Data sent to server, a set of key/value pairs (i.e. form fields and values)
    contentType: false,       // The content type used when sending data to the server.
    cache:false,             // To unable request pages to be cached
    processData:false,        // To send DOMDocument or non processed data file it is set to false
    success: function(data)   // A function to be called if request succeeds
    {
        //alert(data);
        var data1=data.split("~`");
        $('#help_id').val(data1[0]);
        $('#help_title').val(data1[1]);
        $('#help_sdesc').val(data1[2]);                 
    
        editor.setData(''+data1[3]);    
        var edata = editor.getData();
        alert(edata);
    }
    });
    

    Use this code its works for me and (help_ldesc) is my textarea name.

提交回复
热议问题