Cart.php: 从Cart.php调用ajax_cart的ajax代码显示总金额计算的值。单击继续后,我需要在同一页面中显示值..
ajax code
function gettotal(){
$.ajax({
type: "POST",
url: 'ajax_cart_total.php',
data: {action: 'call'},
success: function(html){
alert html;
}
});
}
html
*****
<a class="btn btn-default check_out" href="" onClick="gettotal()">Continue</a>
<li>Total <span id="disp2"></span></li> // value from ajax_cart should be displayed here..
ajax_cart.php: 所需的值取自表格并计算得出总金额
<?php
@mysql_connect("localhost","root","");
mysql_select_db("onlineshopping");
session_start();
$s=$_SESSION['USER']['ID'];
if($_POST['action']=='call'){
$c=mysql_query("select * from totcalcu where USER_ID='$s'");
$cr=mysql_fetch_array($c);
$subt=$cr['SUBTOTAL'];
$tax=$cr['TAX'];
$ship=$cr['SHIPPING_COST'];
$tot=$subt+$tax+$ship; // calculation of total done
?>
<span id="disp2"><?php echo $tot; ?></span>
<?php
$ins=mysql_query("update totcalcu set TOTAL='$tot' where USER_ID='$s'");
}
?>
我无法更改HTML代码..请帮忙