我有以下代码,它将帖子标题显示为列表中的超链接。单击此链接时,它应该显示存储在 ArrayList al 中的帖子的其他详细信息。请帮我怎么做?
protected void Page_Load(object sender, EventArgs e)
{
DB ob = new DB();
string html = "";
ArrayList temp = new ArrayList();
DB.open();
ArrayList al = new ArrayList();
for (int i = 1; i <= 4; i++)
{
al.Add(ob.fetch_post(i));
temp = (ArrayList)al[i-1];
html = html + "<div class=\"spacer\"></div>" + " " + "<div id=\"Title\" +i+"\" class=\"title\">"+ "<a href=\"#\"/>" + temp[0] + "</a> </div>";
}
wrapper_title.InnerHtml = html;
}
我已经包含了ajax函数如下
$(document).ready(function () {
// Add the page method call as an onclick handler for the div.
$("#Title").click(function () {
$.ajax({
type: "POST",
url: "Default.aspx/display",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {
// Replace the div's content with the page method's return.
$("#sidebar1").text(msg.d);
}
});
});
});
现在我面临的问题是,当从 Title1 到 Title4 动态创建 div id 时,我不知道如何调用上述 AJAX 函数。并且还帮助我将 ArrayList al 作为参数从 Ajax 传递到显示 C# 的功能。