action中定义一个得到结果集的方法
public ActionResult GetItemTree(string title, int itemid, int? page) { pp = new PagingParam(page ?? 1, VConfig.WebConstConfig.PageSize); Common.Page.PagedListres_Item_Resource_R = iResourceService.GetRes_Item_Resource_RByItemId(itemid, pp); ViewData["res_Item_Resource_R"] = res_Item_Resource_R; res_Item_Resource_R.AddParameters = new System.Collections.Specialized.NameValueCollection(); res_Item_Resource_R.AddParameters.Add("title", title); res_Item_Resource_R.AddParameters.Add("itemid", itemid.ToString()); ViewResult vr = new ViewResult { ViewData = ViewData, MasterName = "", }; return vr; }
$(function () { var id = '<%=itemid %>'; $.ajax({ type: "POST", url: "/Student/GetItemTree", data: { title: '<%=Model.Name %>', itemid: id, page: 1 }, beforeSend: function (data) { //取回数据前 $("#itemTree").html('数据加载中...'); }, error: function (data) { //发生错误时// debugger; }, success: function (data) { //成功返回时 $("#itemTree").html(data); } });
<%=Html.AjaxPager(resItemResourceBefore, "itemTree", "GetItemTree", "Student")%>