I'm trying to use TinyMCE with JQuery but without success, it sends the textarea data without the formatting, if I try without JQuery it works, does JQuery not accept the html tags inserted by TinyMCE?
Example html part:
<script src="/tinymce/js/tinymce.min.js"></script>
<script>
$(document).ready(function () {
$("#btngravar").on("click", function () {
var form = $(this).parents("form");
var data = $(form).serializeArray();
$.ajax({
type: "POST",
dataType: "json",
url: "pagina.php",
data: data,
complete: function (json, status) {
// alert("passou");
},
success: function (json, status) {
alert("gravou");
},
error: function (json, status) {
alert("erro");
}
});
});
tinymce.init(
{
mode: "exact",
elements: "texto"
});
});
</script>
...
<form action="pagina.php" method="post">
<textarea id="texto" name="texto"></textarea>
<input type="button" id="btngravar" value="gravar"/>
</form>
Example part of PHP:
echo($_POST["texto"]);