通过给后台传递last 和amount两个参数,获取json数组数据。
<script>
mui.init({
swipeBack: false,
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://localhost/amazeui/data.php?action=item",
data: "last="+last+"&amount="+amount,
complete :function(){$("#load").hide();},
success: function(msg){
var data = msg;
var tmp='';
$.each(data, function(i, n){
var li = document.createElement('li');
li.className = 'mui-table-view-cell';
li.innerHTML = '<a class="mui-navigate-right">' + n.itemname + '</a>';
//下拉刷新,新纪录插到最前面;
table.insertBefore(li, table.firstChild);
});
}
});
mui('#pullrefresh').pullRefresh().endPulldownToRefresh(); //refresh completed
}
if (mui.os.plus) {
mui.plusReady(function() {
setTimeout(function() {
mui('#pullrefresh').pullRefresh().pullupLoading();
}, 1000);
});
} else {
mui.ready(function() {
mui('#pullrefresh').pullRefresh().pullupLoading();
});
}
</script>
14 个评论
要回复文章请先登录或注册
sum
6***@qq.com
碌卡
2***@qq.com
邵
Native_O
Native_O
wfc1870
l***@qq.com
demoniu