close
.aspx javascript
var start = 31; //一開始已先預載30筆,所以從31開始 $('.內文_scrollbar').scroll(function () { var scrollHeight = $('.內文_scrollbar')[0].scrollHeight; if ($('.內文_scrollbar').scrollTop() + 800 == scrollHeight) { if (start + 30 <= '<%=內文清單數量%>') { var url = window.location.href.split('cate='); var cate = url[1].split('&id='); $.ajax({ type: 'POST', url: 'WebService.asmx/查詢內文清單by分頁', dataType: 'xml', data: { t1: start, t2: cate[0] }, success: function (oXml) { //alert($('string', oXml).text()); $('#side-menu_內文清單').append($('string', oXml).text()); start = start + 31; }, error: function (xhr, ajaxOptions, thrownError) { alert(xhr.status); alert(thrownError); } }); } } })
WebService
[WebMethod] public string 查詢內文清單by分頁(int t1,string t2) { string sql = "EXECUTE 內文_查詢 @前台顯示=1,@起始行=@p1,@結束行=@p2,@目錄流水號=@p3"; conn.Open(); SqlCommand cmd = new SqlCommand(sql, conn); cmd.Parameters.Add("@p1", SqlDbType.Int, 4).Value = t1; cmd.Parameters.Add("@p2", SqlDbType.Int, 4).Value = t1 + 30; cmd.Parameters.Add("@p3", SqlDbType.NVarChar, 4).Value = t2; SqlDataReader dr = cmd.ExecuteReader(); string 載入的html = ""; while(dr.Read()) { 載入的html = 載入的html + "<li>" + "<a href=\"?cate=" + t2 + "&id=" + dr["內文流水號"].ToString() + "\">" + dr["函式名稱"].ToString() + "</a>" + "</li>"; } dr.Close(); dr.Dispose(); dr = null; if (cmd != null) { cmd.Dispose(); cmd = null; } if (conn != null) { conn.Close(); conn.Dispose(); conn = null; } //連線關閉 return 載入的html; }
全站熱搜
留言列表