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("刷新失败")
}
});
}
0 个回复