我要實現我的ASP.NET web應用程序的JQuery無限滾動後使用數據添加到asp.net表,我用以下的jQuery funcyion(從http://code.msdn.microsoft.com/CSASPNETInfiniteLoading-16f5bdb8拍攝):jQuery函數
$(document).ready(function() {
function lastPostFunc() {
$('#divPostsLoader').html('<img src="images/bigLoader.gif">');
//send a query to server side to present new content
$.ajax({
type: "POST",
url: "Default.aspx/Foo",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (data) {
if (data != "") {
$('.divLoadData:last').after(data.d);
}
$('#divPostsLoader').empty();
}
})
};
divLoadData是一個將接收數據(以HTML格式)的div,但我想將數據追加到一個asp.net表,我如何追加數據?我應該使用功能?還我應該如何生成我的HTML附加到這個服務器端表控制,使用下面的代碼(在將WebMethod功能)當前數據被創建:
foreach (DataRowView myDataRow in dv)
{
getPostsText.AppendFormat("<p>author: {0}</br>", myDataRow["author"]);
getPostsText.AppendFormat("genre: {0}</br>", myDataRow["genre"]);
getPostsText.AppendFormat("price: {0}</br>", myDataRow["price"]);
getPostsText.AppendFormat("publish date: {0}</br>", myDataRow["publish_date"]);
getPostsText.AppendFormat("description: {0}</br></p>", myDataRow["description"]);
}
getPostsText.AppendFormat("<div style='height:15px;'></div>");
最後getPostsText
發送到JQuery的
爲什麼要我將其移出doc_ready的? – 2013-03-25 07:35:34
,因爲你必須在scroll和functions中調用它或者應該在docready中初始化它,或者像在答案中那樣調用它。 – Jai 2013-03-25 07:37:09
我打算在示例中使用div,但沒有將數據添加到我的div中,並且在某些時刻我只看到了我的gif圖像,然後沒有任何內容添加到我的頁面,出了什麼問題? – 2013-03-25 07:40:27