对不起。 我试图让这个过程不起作用。 我有这样的代码:使用Ajax显示php的百分比
function paypalFees($sub_total, $round_fee) {
// Set Fee Rate Variables
$fee_percent = '8'; // Paypal's percentage rate per transaction (3.4% in UK)
$fee_cash = '0.00'; // Paypal's set cash amount per transaction (£0.20 in UK)
// Calculate Fees
$paypal_fee = ((($sub_total/100) * $fee_percent) + $fee_cash);
if ($round_fee == true) {
$paypal_fee = ceil($paypal_fee);
}
// Calculate Grand Total
$grand_total = ($sub_total + $paypal_fee);
// Tidy Up Numbers
$sub_total = number_format($sub_total, 2, '.', ',');
$paypal_fee = number_format($paypal_fee, 2, '.', ',');
$grand_total = number_format($grand_total, 2, '.', ',');
// Return Array
return array('grand_total'=>$grand_total, 'paypal_fee'=>$paypal_fee, 'sub_total'=>$sub_total);
看到的结果我已经把建立一个数字:
$receipt = paypalFees('150.00', false);
结果由
<h2>Your Receipt</h2>
<li>Sub-Total: £<?php print $receipt['sub_total']; ?></li>
<li>Booking Fee: £<?php print $receipt['paypal_fee']; ?></li>
<li>TOTAL: £<?php print $receipt['grand_total']; ?></li>
所示看到的结果我有刷新页面。
如何在没有刷新页面的情况下使用ajax来执行此过程? 一个例子: Sum HTML Textbox Values using jQuery/JavaScript
查看网络套接字,例如http://pusher.com – Utkanos 2014-10-30 13:12:45
您既可以使用AJAX,也可以使用Javascript进行所有计算。 – Barmar 2014-10-30 13:13:25