其他分享
首页 > 其他分享> > 后台查出来的数组显示在页面

后台查出来的数组显示在页面

作者:互联网

HTML页面:

   <div class=" row t1" style="text-align:center;">
            <div class="form-group col-xs-2  col-md-offset-1">
                <div class="panel panel-danger" style="background-color:whitesmoke">
                    <div class="panel-heading" style="background-color:orangered;color:white">
                        <h3 class="panel-title">需扫描数</h3>
                    </div>
                    <div class="panel-body tt" style="color:orangered;font-size:15px;font-weight:bold;" data-key="Scaned">
                        0
                    </div>
                </div>
            </div>
            <div class="form-group col-xs-2  col-md-offset-2">
                <div class="panel panel-success" style="background-color:whitesmoke">
                    <div class="panel-heading" style="background-color:green;color:white">
                        <h3 class="panel-title">已扫描数</h3>
                    </div>
                    <div class="panel-body" style="color:green;font-size:15px;font-weight:bold;" id="tt" data-key="BeScaned">
                        0
                    </div>
                </div>
            </div>
            <div class="form-group col-xs-2 col-md-offset-2">
                <div class="panel panel-default" style="background-color:whitesmoke">
                    <div class="panel-heading" style="background-color:grey;color:white">
                        <h3 class="panel-title">待扫描数</h3>
                    </div>
                    <div class="panel-body" style="font-size:15px;font-weight:bold;" data-key="WaitScaned">
                        0
                    </div>
                </div>
            </div>
        </div>

JavaScript:

$.get(_reqUrl.getData, { MemberName: $.trim(MemberName) }, function (result) {                 
                    var model = result.Custom;                              
                    var t1 = model.t1[0]; //t1 = {Scaned: 2, BeScaned: 0, WaitScaned: 2};            
                    $.each($('.t1').find('div[data-key]'), function (i, m) {
                        $(m).html(t1[$(m).attr('data-key')]);
                    });
                });

效果图:

 

标签:function,MemberName,扫描,t1,var,result,后台,查出来,页面
来源: https://www.cnblogs.com/nanxixi/p/14597510.html