页面本身没错,加上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>

//img2.sycdn.imooc.com/59e0c1120001aa6b13620111.jpg

错过了年华
浏览 1685回答 2
2回答

HalfAnHour

我觉得吧,是你用了smarty模板的原因。{}里面的代码被smarty解析了出现了问题,{literal}<script>......</script>{/literal}看是否可行。

Developer_Zuck

错误说在你的176行,能把代码发完整点吗?
打开App,查看更多内容
随时随地看视频慕课网APP