Skip to content Skip to sidebar Skip to footer

How To Send Data With Ajax Using Ckeditore?

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.

Solution 1:

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 inCKEDITOR.instances)
                CKEDITOR.instances[instance].updateElement();
            var temp = $("#compose_form").serialize();
            etc etc...

Solution 2:

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

<scripttype="text/javascript">for (var instance inCKEDITOR.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

Solution 3:

<scripttype="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

Post a Comment for "How To Send Data With Ajax Using Ckeditore?"