how to send data with ajax using ckeditore?

ckeditor ajax post example
send ckeditor data in ajax
how to get data from ckeditor in jquery
how to get data from ckeditor in php
load ckeditor using ajax
how to display ckeditor data in php
ckeditor data stored in database
ckeditor update content

I have a form in django. it's 'composing mail' form. I send this form from view to my template and i apply ckeditor to chang the body style. i want this form to be posted by ajax. and when ckeditor is used, value of body field isn't send with request.POST. i use this line of code to use ckeditor:

CKEDITOR.replace('id_body'); 

(without using ckeditor, every thing works fine.)

<form id="compose_form" action="compose/" method="post">
        {% csrf_token %}
        {{ form.non_field_errors }}
        <div>
            <div class="form-field">
                <label for="id_recipient">{% trans 'recipient' %}:</label>
                {{ form.recipient }}               
                {{ form.recipient.errors }}
            </div>
            <div class="form-field">
                <label for="id_subject">{% trans 'subject' %}:</label>
                {{ form.subject }}
                {{ form.subject.errors }}
            </div>
        </div>
        <div class="form-field">
            {{ form.body }}
            {{ form.body.errors }}
        </div>        
            <input id="messages-submit" type="submit" value=""Send"/>
        </div>
    </form>

and i use this script to send form data via ajax:

<script type="text/javascript">
        $(function() {
            $('#compose_form').submit(function() {
                var temp = $("#compose_form").serialize();                
                $.ajax({
                    type: "POST",
                    data: temp,
                    url: 'compose/',
                    success: function(data) {
                      // do s.th
                    }
                });
                return false;
            });
        });
    </script>

with this script, body value isn't send to request.POST(i mean it sends empty string in body field), when i add the below line to my script, it sends value of body field, but it isn't ajax any more. Can you please help me what to do?

The reason that the data in the editor isn't included in the form is because the editor isn't a part of the form. It needs to update the form element you have associated it with. For this to happen you need to tell the editor to update the form element.

So in the submit function for your form you need to grab data from the editor.

This should do the trick:

$(function() {
        $('#compose_form').submit(function() {
            for (var instance in CKEDITOR.instances)
                CKEDITOR.instances[instance].updateElement();
            var temp = $("#compose_form").serialize();
            etc etc...

Saving in Ajax Applications, Saving data is a server-side operation and you are free to implement the save data without reloading the page, e.g. in an Ajax application using inline editor,� Cannot send ckeditor data via ajax. Hi, please help me out with this. I cannot send CKEditor html to server side using AJAX post. Here is my code in JQuery:

I also had the same issue with django-ckeditor,What I tried is

<script type="text/javascript">
     for (var instance in CKEDITOR.instances)
            CKEDITOR.instances[instance].updateElement();

then checked the instance name by:

console.log(instance)

it gave "id_Your_Message" ,,So I did:

var temp = $("#id_Your_Message").val() 

it works fine

Cannot send ckeditor data via ajax, Hi, please help me out with this. I cannot send CKEditor html to server side using AJAX post. The user leaves the page before saving the data (e.g. mistakenly closes a tab or clicks some link). The user saved the data, but there are some pending actions like an image upload. To handle the former situation you can listen to the native window#beforeunload event. The latter situation can be handled by using CKEditor 5 PendingActions plugin

<script type="text/javascript">
    $(function () {
        $('#submit_button_id').click(function () {
            $.post("action post file url", $("#form_id").serialize(), function (data) {});
        });
    });
</script>

I hope above script may be help you

Getting and Saving Data, I would use jQuery for this, have a look at http://docs.jquery.com/Ajax/jQuery.post #urldatacallbacktypebut, and a BIG BUT, make sure that you� With inline editing and possibility to create and destroy CKEditor 4 instances dynamically, CKEditor 4 is a perfect match for Ajax applications. Getting updated data from CKEditor 4 is easy thanks to rich JavaScript API.

save fckeditor data with ajax, I am using the following php with ajax to post data on blur to SQL. It works fine passing basic text to the db, but I've added CKeditor to a few� The following samples are available for getting and saving data in CKEditor 4: The Saving Data in CKEditor Replacing a Textarea sample shows how to save data for classic and inline editor replacing a <textarea> element. The CKEditor in Ajax Applications sample shows how to dynamically create and destroy the editor and how to use the change event.

CKEDITOR to dynamically get data from ajax, You can update the textareas by call CKEditor instance function for updating, then check data in JS or send data to server for check and if is� This is an official plugin provided and supported by CKEditor developers. You can submit bug reports directly to its GitHub issues tracker and discuss any integration issues on StackOverflow.

PHP CKeditor post via Ajax on blur stripping html tags, ckeditor dosyaları bu dosya ile aynı dizinde-->. <!-- Bootstrap -->. <! Latest compiled and minified JavaScript --> <form method="post" action="ajax.php" class="ajaxForm"> '<button aria-hidden="true" data-dismiss="alert" class=" close"� In the options parameter, we have specified a type option as a POST, so ajax() method will send http POST request. Also, we have specified data option as a JSON object containing data which will be submitted to the server. So this way you can send GET, POST or PUT request using ajax() method. Visit jQuery documentation to know more about ajax

Comments
  • please handle your own code formatting in future. Also it is usually nice to give a bit of an explanation along with your code so that working solutions dont look like magic.