问答详情
源自:3-2 使用Ajax技术向后台请求数据

这是什么错误?

   <div class="theme-options">
                                        <div class="cart-title number">数量</div>
                                        <dd>
                                        <input id="min" class="am-btn am-btn-default" name="" type="button" value="-" />
                                        <input id="text_box" name="" type="text" value="1" style="width:30px;" />
                                        <input id="add" class="am-btn am-btn-default" name="" type="button" value="+" />
                                        <span id="Stock" class="tb-hidden">库存<span class="stock">1000</span>件</span>
                                        </dd>
                                    </div>
                                    <div class="clear"></div>
                                    <div class="btn-op">
                                        <div class="btn am-btn am-btn-warning">确认</div>
                                        <div class="btn close am-btn am-btn-warning">取消</div>
                                    </div>
                                </div>
                                <div class="theme-signin-right">
                                    <div class="img-info"> <img src="images/songzi.jpg" /> </div>
                                    <div class="text-info"> <span class="J_Price price-now">¥39.00</span> <span id="Stock" class="tb-hidden">库存<span class="stock">1000</span>件</span> </div>
                                </div>
                            </form>
                        </div>
                    </div>
                </dl>
                <div class="clear"></div>
                <!--活动    --> 
                
            </div>
            <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="点此按钮到下一步确认购买信息" href="#">立即购买</a> </div>
                </li>
                <li>
                    <div class="clearfix tb-btn tb-btn-basket theme-login"> <a id="LikBasket" title="加入购物车" href="javascript:addCart({$rst[0]['g_id']})"><i></i>加入购物车</a> </div>
                </li>
            </div>
        </div>
        <div class="clear"></div>
    </div>
    <script type="text/javascript">
          function addCart(g_id){
              var url = "addCart.php";
              var data = {"g_id":g_id,"s_num":parseInt($("#text_box").val())};
              var success= function(response){
                  
              }
              $.post(url,data,success,"json");
          }
    </script>

//img3.sycdn.imooc.com/59e0c0460001aa6b13620111.jpg

提问者:错过了年华 2017-10-13 21:32

个回答

  • 慕粉3767367
    2017-10-25 17:03:17
    已采纳

    语法错误,仔细找找,老师这种php和html混合编写的方式并不推荐,一般来说如果用模板引擎的话,可以直接去缓存内查看生成的html代码哪里错了