Ivan
Ivan

Reputation: 510

incorrect form serialization with jquery

On my CMS, I use marked to public posts, and on form marked put generated html into textarea, when I submit for first time (creating of the new post) form is serialized correctly.

My CMS after creation append's one input (type text) with some specific info and button's to edit and delete, the process is the same but when I try to serialize form:

$(e).serialize() // e ----> '#form'

I see the old value (original) of my textarea, and only after submitting (editing) I get the correct serialized info.

example of bad serializing

I have live preview, so textarea always has recent content. . .

Where can be the problem?

Because if I try to edit post (acessing directly from list of post) everything work's and form is always serialized correctly.

code of function:

var form_submit = function(e, f){
    console.log('FORM')
    e.preventDefault();
    NProgress.start();
    console.log($(f).serialize()+'&req_type=put')
    $.post(
        f.action, $(f).serialize()+'&req_type=put'
    ).success(function(d){
        // ....
    }).error(function(d){
        // ....
    })
}

Upvotes: 0

Views: 561

Answers (1)

Ivan
Ivan

Reputation: 510

After submitting I need to update the "viewed" text of textarea,

solution

so here is a solution for this strange problem....

$('#full_mark').val($('#full_mark').text());

Upvotes: 0

Related Questions