1***@qq.com
1***@qq.com
  • 发布:2017-11-23 10:06
  • 更新:2017-11-23 10:06
  • 阅读:1818

mui下拉刷新获取后台数据

分类:MUI
mui

mui.init({
pullRefresh: {
container: '#pullrefresh',
down: {
callback: pulldownRefresh
},

            }  
        });  
        /**  
         * 下拉刷新具体业务实现  
         */  
        var last = -5,  
            amount = 5;  

        function pulldownRefresh() {  

            last = last + amount;  
            var table = document.body.querySelector('.mui-table-view');  
            var cells = document.body.querySelectorAll('.mui-table-view-cell');  
            mui.ajax({  
                type: "post",  
                dataType: "json",  
                url: "http://www.xinfagc.com:8080/marketitem",  
                data: "last=" + last + "&amount=" + amount,  
                success: function(msg) {  
                    var data = msg;  
                    $.each(data, function(i, n) {  
                        var li = document.createElement('li');  
                        li.className = 'mui-table-view-cell';  
                        li.innerHTML = '<div class="mui-media-body"><p class="mui-ellipsis3">' + n[i].goods_name + '</p></div>';  
                        //下拉刷新,新纪录插到最前面;  
                        table.appendChild(li);  
                        //关闭下拉刷新  
                        mui('#pullrefresh').pullRefresh().endPulldownToRefresh(); //refresh completed  
                    });  
                },  
                error: function(xhr, type, errorThrown) {  
                    //关闭下拉刷新  
                    mui('#pullrefresh').pullRefresh().endPulldownToRefresh(); //refresh completed  
                    alert("刷新失败");  
                    //plus.nativeUI.toast("刷新失败")  
                }  
            });  

        }
2017-11-23 10:06 负责人:无 分享
已邀请:

该问题目前已经被锁定, 无法添加新回复