Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

125
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!