asp+ajax 无刷新新闻列表,点击分页不局部刷新(代码,有下载)
共有2个文件
<!--index.asp-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>公司新闻</title>
<script language="JavaScript" type="text/javascript">
function showpage(n){
document.scripts[1].src = "newslist.asp?page_no=" + n;
}
</script>
</head>
<body>
<div ID="titleLiNews">
</div>
<a href="javascript:showpage(1);">1</a> <a href="javascript:showpage(2);">2</a> <a href="javascript:showpage(3);">3</a>
<script language="JavaScript" type="text/javascript">showpage(1);</script>
</body>
</html>
----------------------------
<!--newslist.asp-->
<%
Dim conn
Set conn=server.createobject("ADODB.connection")
conn.connectionstring="provider=microsoft.jet.oledb.4.0; data source=" & server.mappath("db1.mdb")
conn.open
Dim page_no,sqlstr,rs,i,str
page_no = request.querystring("page_no")
if page_no="" then page_no=10
Sqlstr = "select * from news"
Set rs = Server.CreateObject("ADODB.RecordSet")
Rs.open sqlstr,conn,1,2
Rs.pagesize = 5
Rs.absolutepage = page_no
Str = "document.getElementById('titleLiNews').innerHTML = ""<Ul>"
If rs.eof then str = str & "<li>暂无新闻</li>" & "</Ul>';"
i = 5
Do while not rs.eof and i > 0
i = i-1
str = str & "<li><a href='newsview.asp?id=" & rs("id") & "'>" & rs("title") & "</a></li>"
rs.movenext
Loop
str = str & "</Ul>"";"
set rs=nothing
set conn = nothing
Response.write str
%>
------------------------
参考:http://www.blueidea.com/tech/program/2007/4436.asp
下载:https://files.cnblogs.com/dreamdo/aspajax.rar