第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

購物車怎么點(diǎn)擊一個(gè)按鈕實(shí)時(shí)刷新數(shù)據(jù)顯示出來?

購物車怎么點(diǎn)擊一個(gè)按鈕實(shí)時(shí)刷新數(shù)據(jù)顯示出來?

例如添加一件商品后,某個(gè)div顯示當(dāng)前的商品數(shù)量?<div?class="pay"> ????????????????<div?class="pay-opt">?<a?href="home2.html"><span?class="am-icon-home?am-icon-fw">首頁</span></a>?<a><span?class="am-icon-heart?am-icon-fw">收藏</span></a>?</div> ????????????????<li> ????????????????????<div?class="clearfix?tb-btn?tb-btn-buy?theme-login">?<a?id="LikBuy"?title="點(diǎn)此按鈕到下一步確認(rèn)購買信息"?href="#">立即購買</a>?</div> ????????????????????<div?id="test1"></div> ????????????????</li> ????????????????<li> ????????????????????<div?class="clearfix?tb-btn?tb-btn-basket?theme-login">?<a?id="LikBasket"?title="加入購物車"?href="javascript:addCart({$rst[0]['g_id']})"?onClick="showSum()"><i></i>加入購物車</a>?</div> ????????????????</li> ????????????</div> ????????</div> ????????<div?class="clear"></div> ????</div> ???{literal}?<script?type="text/javascript"> ?????????? ??????????function?showSum(){ ??????????????var?url?=?"countShopcartid.php"; ??????????????? ??????????????? ?????????????var?data?=?{"not":""}; ??????????????var?success=?function(response){ ??????????????????if(response.errno?==?0){ ????????????????????var?sum?=?response.sum;? ????????????????????alert(sum); ??????????????????$("#test1").html(sum); ??????????????????}else ??????????????????{ ???????????????????????alert('獲取購物車商品數(shù)量失敗'); ??????????????????} ??????????????} ??????????????$.post(url,data,success,"json"); ??????????} ????</script>{/literal}countShopcartid.php <?php ? require_once('include.php'); //1.接受參數(shù)并處理 ? $user_id?=?$_SESSION["id"]; //2.計(jì)算數(shù)量 $sql?=?"select?count(*)?from?shopcar?where??user_id='{$user_id}'"; $row?=?$admindb->ExecSQL($sql,$conn); var_dump($row); //3.返回處理結(jié)果 if($row){ ????$response?=?array( ????????'errno'?=>0, ????????'errmsg'?=>'success', ????????'data'?=>?true, ????????'sum'?=>?$row[0]["count(*)"], ????); } else{ ????$response?=?array( ????????'errno'?=>-1, ????????'errmsg'?=>'fail', ????????'data'?=>?false, ????????'sum'?=>?$row[0]["count(*)"], ????); } echo?json_encode($response);??? ?>f12看到sum有值{"errno":0,"errmsg":"success","data":true,"sum":"2"}就是傳不到test1這個(gè)div里
查看完整描述

1 回答

?
慕勒0069038

TA貢獻(xiàn)143條經(jīng)驗(yàn) 獲得超39個(gè)贊

  1. ajax 提交 后臺(tái) , 后臺(tái)入庫 然后將 各個(gè)參數(shù) 返回 通過jquery 修改div 上的數(shù)值

  2. 如果是不需要入庫的話, 直接通過js控制 , jquery 監(jiān)聽button 的點(diǎn)擊事件, 給對(duì)應(yīng)商品加數(shù)字 或者 添加 商品

查看完整回答
反對(duì) 回復(fù) 2017-11-01
  • 1 回答
  • 0 關(guān)注
  • 2310 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)