onclick";“继续”;在Cart.php中,我需要显示一个值"$tot";从cart.php中的ajax_cart.php
Cart.php: ajax代码从cart.php调用ajax_cart以显示总额计算的值。单击“继续”时,我需要在同一页面中显示值onclick";“继续”;在Cart.php中,我需要显示一个值"$tot";从cart.php中的ajax_cart.php,php,ajax,onclick,Php,Ajax,Onclick,Cart.php: ajax代码从cart.php调用ajax_cart以显示总额计算的值。单击“继续”时,我需要在同一页面中显示值 ajax code function gettotal(){ $.ajax({ type: "POST", url: 'ajax_cart_total.php', data: {action: 'call'},
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代码
函数gettotal(){
$.ajax({
类型:“POST”,
url:'ajax\u cart\u total.php',
数据:{action:'call'},
成功:函数(html){
警报html;
}
});
}
html
*****
总计 //此处应显示来自ajax\u购物车的值。。
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'");
}
?>