Ajax Json示例

1

{
    "hotel_id": 1,
    "costs": 3651.78,
    "clicks": 139
  },
  {
    "hotel_id": 2,
    "costs": 2894.62,
    "clicks": 135
  },
  {
    "hotel_id": 3,
    "costs": 4529.45,
    "clicks": 126
  },
  {
    "hotel_id": 4,
    "costs": 3323.65,
    "clicks": 140
  },
  {
    "hotel_id": 5,
    "costs": 4839.67,
    "clicks": 135
  },
  {
    "hotel_id": 6,
    "costs": 4701.21,
    "clicks": 135
  },
  {
    "hotel_id": 7,
    "costs": 3444.94,
    "clicks": 144
  },
  {
    "hotel_id": 8,
    "costs": 5067.62,
    "clicks": 132
  },
  {
    "hotel_id": 9,
    "costs": 2256.84,
    "clicks": 118
  },
  {
    "hotel_id": 36,
    "costs": 3475.65,
    "clicks": 123
  }


 $.ajax({
                url:"${contextPath}/hotel/get-hotel-info-byDate-ajax.html",
                cache: false,
                type : "POST",
                data:{"hotelIdArray[]":hotelIdArray},

                success:function(data) {
                    var flag =  "${SESSION_KEY_ACCOUNT_CURRENCY_SUFFIX}";
                    for(var i=0;i< hotelIdArray.length;i++){//不存在的初始化为0
                        var t_hotel = hotelIdArray[i];
                        $('#costNum_'+t_hotel).html(flag+'0');
                        $('#clickNum_'+t_hotel).html(0);
                    }

                    for(var i=0;i< data.length;i++){
                        var tmpId = data[i].hotel_id;
                        var tmpCost = data[i].costs;
                        var tmpClick = data[i].clicks;

                        var costNum = "costNum_"+tmpId;
                        var clickNum = "clickNum_"+tmpId;

                        if(tmpCost==undefined||tmpCost==null) tmpCost = 0;
                        if(tmpClick==undefined||tmpClick==null) tmpClick = 0;
                        var cost = formatCurrencyWithDecimal(tmpCost, flag, 0)

                        $('#'+costNum).html(cost);
                        $('#'+clickNum).html(tmpClick);

                    }
                },
                error: function(data) {
                   // alert("error");
                }
            });
        }



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值