使用asp.net中的jquery在向下滚动时加载更多数据 [英] load more data on scroll down using jquery in asp.net
问题描述
数据将在向下滚动事件中加载,但不会附加到数据列表上
请帮助我。
我的代码是
< script type =text / javascript>
var pageIndex = 1;
var pageCount;
$(窗口).scroll(function(){
if($(window).scrollTop()== $(document).height() - $(window).height( )){
GetRecords();
}
});
函数GetRecords(){
pageIndex ++;
if(pageIndex == 2 || pageIndex< = pageCount){
$(#loader)。show() ;
$ .ajax({
类型:POST,
url:Collapsepage.aspx / GetCustomers,
数据:'{pageIndex:'+ pageIndex +'}',
contentType:application / json; charset = utf-8,
dataType: json,
成功:OnSuccess,
失败:功能(响应){
alert(失败+响应d);
},
错误:功能(响应){
alert(response.d);
}
}); < br b> b $ b $
函数OnSuccess(响应){
var xmlDoc = $ .parseXML(response.d) ;
var xml = $(xmlDoc);
pageCount = parseInt(xml.find(PageCount)。eq(0).find(PageCount)。 text());
var customers = xml.find(Customers);
customers.each(function(){
var customer = $(this);
var table = $(#dlistcmplist table)。eq(0).clone(true);
$(。CName ,表格.html(customer.find(CName)。text());
$(。BID,表格).html(customer.find(BID)。 text());
$(。STD,表格).html(customer.find(STD)。text());
$( .SLName,table).html(customer.find(SLName)。text());
$(。LName,table).html(customer.find(LName) ).text());
$(。CGName,表格).html(customer.find(CGName)。text());
$ (。CLogo,表格).html(customer.find(CLogo)。text());
$(。B_Addr,表格).html(customer.find( B_Addr)。text());
$(。BrdNo,表格).html(customer.find(BrdNo)。text());
$(。MbleNo,表格).html(customer.find(MbleNo)。text());
$(。TFN,table).html(customer.find (TFN)。text());
$(。rate,table).html(customer.find(rate)。text());
$(。StCount,表格).html(customer.find(StCount)。text());
$(。Other,table).html(customer .find(Other)。text());
$(。PageIndex,ta ble).html(customer.find(PageIndex)。text());
$(。PageText,table).html(customer.find(PageText)。text( ));
$(。CCount,表格).html(customer.find(CCount)。text());
$(。CGID ,table).html(customer.find(CGID)。text());
$(。SMSNO,表格).html(customer.find(SMSNO)。 text());
$(#dlistcmplist)。append(table).append(
);
GetReloadUpdatePanel()
alert(成功+响应d);
});
$(#loader)。hide();
}
< / script>
(window).scroll(function(){
if(
(window).scrollTop()==
< blockquote>(document).height() -
the data will be loaded on scroll down event but it is not append to the datalist
plz help me.
my code is
<script type="text/javascript">
var pageIndex = 1;
var pageCount;
$(window).scroll(function () {
if ($(window).scrollTop() == $(document).height() - $(window).height()) {
GetRecords();
}
});
function GetRecords() {
pageIndex++;
if (pageIndex == 2 || pageIndex <= pageCount) {
$("#loader").show();
$.ajax({
type: "POST",
url: "Collapsepage.aspx/GetCustomers",
data: '{pageIndex: ' + pageIndex + '}',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: OnSuccess,
failure: function (response) {
alert("failure"+response.d);
},
error: function (response) {
alert(response.d);
}
});
}
}
function OnSuccess(response) {
var xmlDoc = $.parseXML(response.d);
var xml = $(xmlDoc);
pageCount = parseInt(xml.find("PageCount").eq(0).find("PageCount").text());
var customers = xml.find("Customers");
customers.each(function () {
var customer = $(this);
var table = $("#dlistcmplist table").eq(0).clone(true);
$(".CName", table).html(customer.find("CName").text());
$(".BID", table).html(customer.find("BID").text());
$(".STD", table).html(customer.find("STD").text());
$(".SLName", table).html(customer.find("SLName").text());
$(".LName", table).html(customer.find("LName").text());
$(".CGName", table).html(customer.find("CGName").text());
$(".CLogo", table).html(customer.find("CLogo").text());
$(".B_Addr", table).html(customer.find("B_Addr").text());
$(".BrdNo", table).html(customer.find("BrdNo").text());
$(".MbleNo", table).html(customer.find("MbleNo").text());
$(".TFN", table).html(customer.find("TFN").text());
$(".rate", table).html(customer.find("rate").text());
$(".StCount", table).html(customer.find("StCount").text());
$(".Other", table).html(customer.find("Other").text());
$(".PageIndex", table).html(customer.find("PageIndex").text());
$(".PageText", table).html(customer.find("PageText").text());
$(".CCount", table).html(customer.find("CCount").text());
$(".CGID", table).html(customer.find("CGID").text());
$(".SMSNO", table).html(customer.find("SMSNO").text());
$("#dlistcmplist").append(table).append("
");
GetReloadUpdatePanel()
alert("success" + response.d);
});
$("#loader").hide();
}
</script>
(window).scroll(function () {
if (
(window).scrollTop() ==
(document).height() -
这篇关于使用asp.net中的jquery在向下滚动时加载更多数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!