0

I created a website & added CKEditor.. I have a form with 3 normal input fields and then a textarea which is replaced by the CKEditor. But When i submit the form, value of CKEditor isn't showing up.

HTML:

<form id="pform" method="post">
    <input class="poster_name" type="text" name="poster_name" placeholder="Namn">
    <input class="title" type="text" name="title" placeholder="Titel">
    <input class="subject" type="text" name="subject" placeholder="Ämne">
    <textarea name="article" id="editor1"></textarea>
    <script>
    // Replace the <textarea id="editor1"> with a CKEditor
    // instance, using default configuration.
    CKEDITOR.replace('editor1');
    </script>
    <a class="submit_postform">Send</a>
</form>

JQUERY:

$('.submit_postform').click(function(){
    $.ajax({
       url:'pages/post.php',
       type: 'POST',
       data: $('#pform').serialize(),
       success: function(data) {
          alert(data);
          $('.poster_name').val('');
          $('.title').val('');
          $('.subject').val('');
       }
    });
});

1 Answer 1

1

That's because the data from the CKEDITOR "moved" to the textarea only before submitting - so you won't see the content in the textarea using .val(). You can access CKEDITOR directly to get the data:

var editor = CKEDITOR.instances['DOM-ID-HERE'].getData();
Sign up to request clarification or add additional context in comments.

3 Comments

How do I do in order to put that value inside of the serialized data?
data: $('#pform').serialize(),
Thnx, that helped.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.