Hello. My form is sent by Ajax. I use tinymce 4.4.1. But when sent to the server, the body field is empty. With Google, I understood that tinymce needs to save data, but I don’t know how. Here is the code

 $('#form').on('submit', function(e) { e.preventDefault(); var form = $('#form'); var formData = form.serialize(); $.ajax({ url : form.attr("action"), type : 'patch', data : formData, dataType: 'json', cache: false, headers: { 'X-CSRF-TOKEN': $('meta[name="_token"]').attr('content') }, error :function( errors ) { output = "<div class='alert alert-danger'><h4><i class='icon fa fa-ban'></i> Возникла ошибка</h4><ul>"; $.each(errors.responseJSON, function(index, error){ output += "<li>" + error + "</li>"; }); output += "</ul></div>"; $('#append').html(output); }, success: function(data){ output = "<div class='alert alert-success'><h4><i class='icon fa fa-check'></i> Готово</h4>"; output += data.success; output += "</div>"; $('#append').html(output); setTimeout(function(){ window.location.replace('{{ url('panel/article') }}')}, 3500 ); } }) }); 

That's what's in the array array going to server

    2 answers 2

    To get content from the editor, you can use the getContent method .

     tinymce.editors[n].getContent() 

    Instead of n index of the editor from which you want to pull out the content.

    • And how to keep the received content in the field? - Alex_01
    • var body = tinymce.editors['body'].getContent(); I send so data : formData + '&body=' +body, - Alex_01

    I finally found this solution:

      for (var i = 0; i < tinymce.editors.length; i++) { tinymce.editors[i].save(); } 

    tinymce v 4.0