Send print data to another page

Asked

Viewed 65 times

0

I need to send some information to another page for printing, I have already been able to validate the information, but I don’t know how to call the other page and print the data provided by the user. What I got is this:

The validation:

$(function() {

  $('#frmCadastro').validate({
    rules: {
      Unicoop: {
        required: true
      },
      Empregado: {
        required: true
      },
      CTPS: {
        required: true
      },
      SCTPS: {
        required: true
      },
      Dias: {
        required: true
      },
      Data: {
        required: true
      }
    },
    // Messages for form validation
    messages: {
      Unicoop: {
        required: ''
      },
      Empregado: {
        required: ''
      },
      CTPS: {
        required: ''
      },
      SCTPS: {
        required: ''
      },
      Dias: {
        required: ''
      },
      Data: {
        required: ''
      }
    },

    submitHandler: function(form) {
      var data = $(form).serialize();
      //event.preventDefault();
      $.ajax({
        url: "pImprimeTermoProrrogacao.php",
        type: 'POST',
        datatype: 'json',
        data: data,
        success: function(data) {
          console.log(data);
        }
      });
      return false;

    }
  });

});

My.log() console shows me what needs to be on the other page for printing.

<table width="80%" border="0" align="center">
  <tbody>
    <tr>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
        <tr>
      <td colspan="3">Por mútuo acordo que fazem a EMPRESA TAL, Estabelecimento NOME EMPRESA, devidamente inscrito no CNPJ sob o nº XX.XXX.XXX/XXXX-XX situado à Rodovia BR 376 Km 395, na cidade de CIDADE, Estado do PR, doravante denominada simplesmente EMPREGADORA, e o Sr Rafaela Santos de Souza, portador da Carteira Profissional nº 2545-89 Série 48512, a seguir denominado simplesmente EMPREGADO, fica o Contrato de Experiência por esta assinado, que deveria vencer nesta data, prorrogado por mais 50 dias, com data definitiva de 08/08/2017.</td>
    </tr>
        <tr>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
  </tbody>
</table>

  • impossible to do qq test with the displayed codes

1 answer

2


From what I understand, you need PHP information sent to print.

Instead of your.log console switch to the code below:

var janela = window.open("","","width=200,height=100"); // abre janela
janela.document.write(data); // escreve a info na janela
janela.focus(); // seleciona a janela
janela.print(); // chama a impressão
  • Perfect, thank you very much @Bruno Folle, helped a lot.

  • adventistapr, You’re welcome :)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.