W
W
WeStlik2021-02-12 13:38:22
HTML
WeStlik, 2021-02-12 13:38:22

Why is the TEXTAREA value not passed when submitting a form via AJAX?

Good day!
The website has a form:

form code

<code lang="javascript">
tinymce.init({
  selector: '#textarea';
})
</code>
<form action="" method="post" accept-charset="utf-8" enctype="multipart/form-data">
<!-- ДРУГИЕ ПОЛЯ -->
<b>Описание:</b>
<textarea name="textarea" cols="40" rows="10" class="tinymce" id="textarea"><?=$desc?></textarea>
</form>



The form is submitted by AJAX via new FormData(this):
form submission

form.on('submit', function(event) {
var formData = new FormData(this);
for (var id in queue) {
formData.append('iconfile[]', queue[id]);
}
$.ajax({
url: $(this).attr('action'),
type: 'POST',
data: formData,
processData: false,
contentType: false,
success: function (res) {
alert(res);
}
});
});


The problem is that all fields are sent except for the description.
The description is sent only FROM THE SECOND TIME, i.е. OK is displayed, but the description does not change, and if the form is submitted 2 times, OK will be displayed, respectively, 2 times, and only then the description will change.

This problem is with both TinyMCE and CKEditor.
If you submit the form without AJAX, then everything will work as it should.

Question... what's the problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
WeStlik, 2021-02-12
@WeStlik

Answer found.
Thanks Georgy Eremeev and galaxy
If it helps someone:
In the submit event of the form, at the very beginning:
tinyMCE.triggerSave();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question