Recover textarea value in form . serialize()

Asked

Viewed 1,213 times

2

I’ve always used generic function, but I’m having a problem recovering the value of textarea. I use a text editor on textarea, the Ckeditor.

Here follows the function I’m using:

function sendPost(form, action, callback) {
    ajaxRequest == null ? ajaxRequest = null : ajaxRequest.abort();
    if (validateForm($("#" + form))) {
        var msg;
        alert($("#"+form).serialize()); 
        //Utilizei esse alert acima, só para verificar como o POST está indo
        ajaxRequest = $.post("crud/" + action + ".php", $("#" + form).serialize(),
            function (data) {
                dataFromAjaxRequest(data, callback);
            });
    } else {
        $("#dialog_modal_mensagem").dialog("open");
    }
}

The exit of alert:

titulo=teste&data=03%2F04%2F2014&texto=

1 answer

2


You have to update the fields related to Ckeditor, before using the serialize:

for ( instance in CKEDITOR.instances )
    CKEDITOR.instances[instance].updateElement();

After that, the Ckeditor field will be filled in, and should work.

Reference:

How to ajax-Submit a form textarea input from Ckeditor?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.