I want to save the form data with ajax. I can pass all fields to DB but textarea with tinymce implemented. My method is 'onblur'. When remove a cursor from an element the ajax is triggered.
tinymce.init({
selector: 'textarea',
plugins: 'code image example',
toolbar: 'alignleft,aligncenter,alignright | code | image example',
statusbar: false,
menubar: true,
});
$('#food_form').on('keyup change paste blur', 'input, select, textarea', function() {
$.ajax({
url: 'food_db.php',//send form info here
type: 'POST',
data: $('#food_adder').serialize(),
success: function(resp) {
$('#resp').html(resp).show();//show result from ajax
}
}); //ajax
}); //on key change
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tinymce/4.7.4/tinymce.min.js"></script>
<form id="food_form">
<input type="text" name="title" placeholder="Menu title"/>
<textarea name="desc" placeholder="Put your instruction here"></textarea>
</form>
I want 'textarea' to trigger the ajax to save data as well as input. I tested on my server and it works well with no error. Just wondering how to trigger the ajax with 'textarea' with tinymce applied to.
fiddle : http://jsfiddle.net/14bq59tw/