现在希望达成的效果是页面加载显示10条,每次下拉刷新出5条这样,但是现在只能把传过来的数据全部循环输出,希望大神帮忙把分页刷新帮我改好。小弟这里感激不尽!!
mui.init({
pullRefresh: {
container: '#pullrefresh',
up: {
auto: true,
callback: pullupRefresh
}
}
})
function pullupRefresh() {
setTimeout(function() {
var table = document.body.querySelector('.mui-table-view');
var cells = document.body.querySelectorAll('.mui-table-view-cell');
mui.ajax('control.php',{
data:{
as:'df'
},
dataType:'json',//服务器返回json格式数据
type:'post',//HTTP请求类型
timeout:10000,//超时时间设置为10秒;
headers:{'Content-Type':'application/json'},
success:function(data){
var data = data;
//var list_str = JSON.stringify(data);
//var list_arr = list_str.split(",");
//alert(data);
mui.each(data,function(index,item){
var li = document.createElement('li');
li.className = 'mui-table-view-cell';
li.innerHTML = '<a class="mui-navigate-right" href="//ask.dcloud.net.cn/">'
'<img src="images/l1.png">'
'<span>'
data[index]
'</span></a>';
//下拉刷新,新纪录插到最前面;
table.insertBefore(li, table.firstChild);
})
}
});
mui('#pullrefresh').pullRefresh().endPullupToRefresh(); //refresh completed
}, 1500)
}
0 个回复