Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

126
Visualizações
ajax call for a Post method without form

I'm using a simple form to print an pdf file using tcpdf. With the form the pdf is well generated on a new page printOrder.php

    <form action="php_action/printOrder.php" method="POST" target="_blank">
        <input type="text" name="orderId" id="orderId">

        <input type="submit" name="submit_btn">

    </form>

Now instead of using a form i would like to use a jquery function on aclick event that post the data and open the pdf on the new page printOrder.php. I have tried but this is not working. (Error : Warning: Undefined variable $pdf)

function printOrder(orderId = null) {
    if (orderId) {
        $.ajax({
            url: 'php_action/printOrder.php',
            type: 'post',
            data: { orderId: orderId },
            dataType: 'text',
            success: function (response) {

                var w = window.open('php_action/printOrder.php');
                w.document.open();
                w.document.write(response);
                

            }// /
        }); // /
    } // /if orderId
} // /
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda