I have a link with javascript onclick function that gets html code from current page say a.php sends to javascript file script.js to edit it and now should go to destination php file print_invoice.php.
I have successfully sent data from php to javascript file and edited the data. Now i want to send to print_invoice.php. See my code below:
a.php
<td><a id="getinfo" href="print_invoice.php?invoice_id='.$invoiceDetails["order_id"].'" onclick="invoice_ajax('.count(getInvoiceItems($invoiceDetails["order_id"])).')" data-info="'.base64_encode($template).'" title="Print Invoice"><span class="glyphicon glyphicon-print"></span></a></td>
script.js
var data = 'targetData';
var variableToSend = 'foo';
$.post('print_invoice.php', {variable: variableToSend});
print_invoice.php
$variable = $_POST['variable'];
echo $variable;