我要实现我的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