Home » Jquery » javascript – set value in ckeditor using jQuery-Exceptionshub

javascript – set value in ckeditor using jQuery-Exceptionshub

Posted by: admin February 24, 2020 Leave a comment

Questions:

I have ckEditor in my page.I want to append my new jquery variable value with old value in my CKEditor.

<asp:TextBox TextMode="multiLine" class="span4" ID="txtDescription"
Rows="10" Columns="80" runat="server" MaxLength="300" Style="border: solid 1px #e7e7e7; 
background: none repeat scroll 0 0 #E7E7E7;">
</asp:TextBox>

<div id="imgDiv"></div>
<script type="text/javascript">
CKEDITOR.config.toolbar_MA = [['Source', '-', 'Print', 'Cut', 'Copy', 'Paste', '-', 'Undo', 'Redo', 'RemoveFormat', '-', 'Link', 'Unlink', 'Anchor', '-', 'Image', 'Table', 'HorizontalRule', 'SpecialChar'], '/', ['Format', 'Templates', 'Bold', 'Italic', 'Underline', '-', 'Superscript', '-', ['JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock'], '-', 'NumberedList', 'BulletedList', '-', 'Outdent', 'Indent']];

CKEDITOR.replace('<%= txtDescription.ClientID %>', { baseHref: '<%= ResolveUrl("~/ckeditor/") %>', height: 150, toolbar: 'MA' });

</script>

Here is jquery code in which I have variable “n”.
I want to append the value of “n” with old CK Editor value.

 $("#imgDiv").on("click", function (event) {
                var offset = $(this).offset();
                var x = "186";
                var y = "374";
                $.ajax({

                    type: "POST",

                    url: "Section.aspx/GetCordiData",

                    //data: '',
                    data: JSON.stringify({ 'xGet': x, 'yGet': y }),

                    contentType: "application/json; charset=utf-8",

                    dataType: "json",

                    success: function (data) {

                        //alert("Success");
                        //console.log(data);
                        var imgcordival = JSON.parse(data.d);
                        $.each(imgcordival, function (i, jsondata) {
                            var n = jsondata.HotSpotDescription;
                            alert(n);
                        });

                    }

                });
            });
How to&Answer: