Resolve editing of textarea with jQuery

0

I'm doing an event registration, with PHP and jQuery, to register everything happens fine, but when I'm going to change, it causes an error:

Example:
We all know that when we enter a page to edit, we have to have the fields filled already with the database data, that's a fact.

But when I change the text of textarea , and click on submit , my database does not change the field, and even trying to show in the console, the new content does not show on console, displays the text of the database.

My HTML field:

<textarea name="post_content" id="post_content" class="form-control tinymce"><?=$result->post_content;?></textarea>

This is the variable:

var descricao_edit = j("textarea[name='post_content']").val();

JavaScript Script:

<script type="text/javascript">
    var j = jQuery.noConflict();
    j(document).ready(function () {
        var base_url = window.location.origin;
        var btn_enviar = j('#cadastro-dados');

        btn_enviar.on('click', function (event) {
            var base_url = window.location.origin;
            event.preventDefault();

            var categoria = j("input[type=radio][name=post_category]").val();
            var subcategoria = j("#post_category_parent").val();
            var titulo = j("#post_title").val();
            var descricao = j("#post_content").val();
            var id = j("#post_author").val();

            j.ajax({
                url: "<?= INCLUDE_PATH; ?>/modulos/cadastro_evento.php",
                type: 'POST',
                data: 'acao=dados&id=' + id + '&categoria=' + categoria + '&sub=' + subcategoria + '&titulo=' + titulo + '&descricao=' + descricao,
                beforeSend: function () {
                    btn_enviar.attr("disabled", true);
                },
                success: function (data) {
                    j.gritter.add({
                        title: '<i class="fa fa-check"></i> Sucesso!',
                        text: 'Dados registrados com sucesso.',
                        sticky: false,
                        time: ''
                    });

                    btn_enviar.attr("disabled", false);
                    window.location.href = base_url + "/editar/" + data;                    
                },
                error: function (data) {
                    if (data == 'erro') {
                        btn_enviar.attr("disabled", false);
                        alert('Erro ao tentar registrar');
                    }                   
                }
            });
        });
    });
</script>
    
asked by anonymous 07.07.2017 / 21:26

0 answers