インターネット上のどこかから次の JQuery コードを使用して、ブラウザ ウィンドウのスクロールでコンテンツをロードしています。
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: "CS.aspx/GetCustomers",
data: '{pageIndex: ' + pageIndex + '}',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: OnSuccess,
failure: function (response) {
alert(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 = $("#dvCustomers table").eq(0).clone(true);
$(".name", table).html(customer.find("ContactName").text());
$(".city", table).html(customer.find("City").text());
$(".postal", table).html(customer.find("PostalCode").text());
$(".country", table).html(customer.find("Country").text());
$(".phone", table).html(customer.find("Phone").text());
$(".fax", table).html(customer.find("Fax").text());
$("#dvCustomers").append(table).append("<br />");
});
$("#loader").hide();
}
ご覧のとおり、応答の成功に関する HTML テーブルが追加されています。しかし、コンテンツがスクロールするときに、この HTML テーブルの代わりに追加したい asp.net ユーザー コントロールがあります (つまり、JQuery からサーバー側コントロールを追加したいのです)。この HTML テーブルの代わりにユーザー コントロールの HTML を追加することはできません。そのコードは長すぎて複雑であり、JQuery についてあまり知らないからです。私は JQuery の初心者概念の初心者です。さらに、私はバックエンド プログラミングのスペシャリストです。したがって、そのビジネス ロジックを JQuery でコーディングすることはできません。だから、誰でもそうするのを手伝ってください。