多个选型卡切换后,缓加载

 

 

 !function () {
            var flowInfo = {
                type1: 2,
                type2: 2,
                type3: 2,
                type4: 2,
                type5: 2
            }

            $(window).on("scroll", getFlowCont);
            var isGet = true;
            function getFlowCont() {
                var wtop = $(window).scrollTop(), wh = $(window).height();
                if (wtop + wh + 200 > $(document).height()) {
                    var i = $(".info-flow-nav .active").index() + 1;
                    console.log("开始加载数据");
                    if (isGet) {

                        if (flowInfo['type' + i] > 5) {
                            isGet = false;
                            return;
                        }

                        var url = "/xxxx.aspx?op=" + i + "&pageindex=" + flowInfo['type' + i];
                        $.ajax({
                            url: url, async: false, cache: false,
                            success: function (data) {
                                flowInfo['type' + i]++;
                                $(".info-flow-cont").eq(i - 1).append(data);
                                isGet = true;

                            },
                            error: function () {
                                console.log("请求失败");
                            }
                        });
                    }
                }
            }
        }()

 

posted on 2018-01-16 16:26  奔游浪子  阅读(83)  评论(0)    收藏  举报

导航