﻿//第一次呈现由服务端完成，投票项目，类型等有服务端生成。，客户端负责：2.提交投票数据。3。返回投票结果数据
//购物车商品数量控件js文件
$(document).ready(function() {
    //商品数量ajax
    $(".cartBox").each(function() {
        var myCartBox = $(this);
        //显示ajax请求loading,在ajax请求时调用
        function showAjaxLoading() {
            myCartBox.find(".loading").show("normal");
        }
        //隐藏ajax请求loading
        function hideAjaxLoading() {
            myCartBox.find(".loading").hide("normal");
        }
        //ajax返回购物车数据
        showAjaxLoading();
        $.ajax({
            type: "POST",
            contentType: "application/json",
            url: "WebService/WS_GoodCountBox.asmx/GetCartInfo",
            data: "{}",
            dataType: 'json',
            success: function(result) {
                if (result!="null") {
                    myCartBox.find(".goodsCount").text(result[0]);
					myCartBox.find(".gross").text(result[1]);
                }
                hideAjaxLoading();
            },
			error: function(XMLHttpRequest, textStatus, errorThrown) {
				myCartBox.find(".goodsCount").text("error");
				myCartBox.find(".gross").text("error");
				hideAjaxLoading();
			}
        });
        
    });
})