CkEditor Fills data in URL when sending

1

Good morning guys.

Have you ever seen this problem while using Ckeditor?

I have a form where my <textarea></textarea> text box is replaced by the Ckeditor text editor.

I have this on my page:

<form class="panel input-group col-md-12" id="form_relatorio">
                    <textarea id="texto_relatorio" name="texto_relatorio" class="form-control" placeholder="Digite nesse espaço o Relatório de Serviço"></textarea>

                    <script>
                            CKEDITOR.replace( 'texto_relatorio', {  enterMode : CKEDITOR.ENTER_BR, shiftEnterMode : CKEDITOR.ENTER_BR } );
                             CKEDITOR.on( 'instanceReady', function( ev )
                            {
                             ev.editor.dataProcessor.writer.setRules( 'br',
                             {
                                indent : false,
                                breakBeforeOpen : false,
                                breakAfterOpen : false,
                                breakBeforeClose : false,
                                breakAfterClose : false
                             });
                        });

                    </script>
                    <div class="form-group row" >
                        <label for="data_relatorio" class="col-xs-3 col-form-label">Data do Chamado: </label>
                        <div class="col-xs-3">
                            <input class="form-control" type="date" id="data_relatorio" name="data_relatorio" value="<?php echo date("Y-m-d");?>">
                        </div>
                    </div>              
                    <div class="form-group row">
                        <label for="empresas" class="col-xs-3">Serviço Prestado à:</label>
                        <div class="col-xs-3">
                            <select class="form-control" type="search" name="empresas" id="empresas">    
                                <option value="Avulso">Avulso</option>                          
                                <option value="cliente1">Cliente 1</option>
                                <option value="cliente2">Cliente 2</option>
                                <option value="cliente3">Cliente 3</option>                                                         
                            </select>
                        </div>
                    </div>

                        <button class="btn btn-primary btn-block" id="btn_relatorio" type="submit">Enviar</button>                          

                </form>

And at the beginning of my page in my header.php file I have the form submission and Ckeditor opening:

$('#btn_relatorio').click( function(){

        for(var instanceName in CKEDITOR.instances)
        CKEDITOR.instances[instanceName].updateElement();


        if($('#texto_relatorio').val(). length > 0){                
            $.ajax({
                url: 'inc/envia_relatorio.php',
                method: 'post',
                data: $('#form_relatorio').serialize(),
                sucess: function(data){                     
                    $('#texto_relatorio').val('');
                        atualizaRelatorio();
                        return false;                           
                }
            });
        }               

    });

He's doing everything right. Sending to my database, with all correct formatting. My problem is that whenever I give the submit in the form, all my variables go to the URL, getting giant an example it looks like this: http://local.mentec.com.br/sistema/relatorios?texto_relatorio=teste&data_relatorio=2017-11-05&empresas=Avulso

As if I just sent by GET. I believe that the data that is going is textarea before the Ckeditor. Is there any way to "bar" this text from going to the URL?

If I send a 2 or 3 forms then I already get error from a very extensive URL of my server and will not let me send the data, so I need to either reload the page or clear the URL.

Thanks guys, hugs

    
asked by anonymous 05.11.2017 / 14:43

1 answer

0

Ah, let me tell you guys, I've found a function that you can use in CKEditor itself, SetData ('').

Looking like this:

$('#btn_relatorio').click( function(){

        for(var instanceName in CKEDITOR.instances)
        CKEDITOR.instances[instanceName].updateElement();
        CKEDITOR.instances[instanceName].setData('');


        if($('#texto_relatorio').val(). length > 0){                
            $.ajax({
                url: 'inc/envia_relatorio.php',
                method: 'post',
                data: $('#form_relatorio').serialize(),
                sucess: function(data){                     
                    $('#texto_relatorio').val('');
                        atualizaRelatorio();
                        return false;                           
                }
            });
        }   return false;           

    });

From this I replace my submit type Button to type="button" And I add return false; to the end of my IF to clear the field and not submit it via URL.

Thanks O7

    
05.11.2017 / 14:51