如何用ajax实现mui下拉列表
2016-09-01
展开全部
<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>
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>
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询