📄 ajax分页查询程序 - ajax - 4s资讯社--分享与交流.htm
字号:
href="tag.php?name=%B2%CE%CA%FD">参数</SPAN>,Method是用来判断要执行什么查询,"ROW1",
"ROW2"表示要查询的记录范围,其他的<SPAN class=t_tag onclick=tagshow(event)
href="tag.php?name=%B2%CE%CA%FD">参数</SPAN>就根据实际需要进行调整。ShowCarTrack(val)是一个对查询结果进行处理的函数,异步调用完成后得到的结果就将在这个函数中分析处理并且显示。这部分代码按照具体实现编写,我这里就不列出。
<DIV class=blockcode>
<H5>代码:</H5><CODE id=code2>function TurnPage(val)<BR>{<BR> if
(Number(val) != CurPage) {<BR> <BR>
CurPage = Number(val);<BR>
<BR> var row1 =
String((CurPage - 1) * 50 + 1);<BR> var
row2 = String(CurPage * 50);<BR> <BR>
var trackinfo =
document.getElementById("div_trackpoint");<BR>
trackinfo.innerHTML =
" 获取数据中,请稍等...";<BR>_cscCustomAnalyst(["Method", "SID", "TIME1", "TIME2",
"ROW1", "ROW2"], <BR>
["GetCarTrack",,
"80100117", t1, t2, row1, row2],<BR>
ShowCarTrack,onQueryError);<BR>
<BR>
if (CurPage == 1) TurnTab(0);<BR>
<BR> if
(CurPage == TotalPage) TurnTab(-2); <BR>
<BR> var statusinfo =
document.getElementById("div_trackpage_status");<BR>
<BR> statusinfo.innerHTML
= "第" + CurPage + "页";<BR> }<BR>}<BR>
NextPage切换下一页,调用TurnPage实现,如果下一页超出当前分组则要切换到下一分组。<BR>function
NextPage()<BR>{<BR> if (CurPage < TotalPage) {<BR>
<BR> TurnPage(CurPage+1);<BR>
<BR> if
((CurPage + 1) > (CurTab * PageTab)) {<BR>
TurnTab(1);<BR>
}<BR> }<BR> <BR>}<BR>
PreviousPage切换上一页,调用TurnPage实现,如果上一页超出当前分组则要切换到上一分组。<BR>function
PreviousPage()<BR>{<BR> if (CurPage > 1) {<BR>
TurnPage(CurPage-1);<BR>
<BR> if ((CurPage - 1)
<= ((CurTab - 1) * PageTab)) {<BR>
TurnTab(-1);<BR>
}<BR> <BR>
}<BR>}<BR>
_cscCustomAnalyst是异步调用函数,xhr.open("post","MapQuery.ashx",
true);这段话是表示将请求提交到MapQuery.ashx这个页面。所有的<SPAN class=t_tag onclick=tagshow(event)
href="tag.php?name=%B7%FE%CE%F1%C6%F7">服务器</SPAN>段<SPAN class=t_tag
onclick=tagshow(event)
href="tag.php?name=%CA%FD%BE%DD%BF%E2">数据库</SPAN>操作都在MapQuery.ashx里面执行。<BR>function
_cscCustomAnalyst(paramNames, paramValues, onComplete, onError){<BR>
<BR> var xhr=_GetXmlHttpRequest();<BR>
<BR> xhr.open("post","MapQuery.ashx", true);<BR>
xhr.setRequestHeader("Content-Type",
"application/x-www-form-urlencoded");<BR> <BR>
xhr.onreadystatechange=function(){<BR> <BR>
var readyState=xhr.readyState;<BR>if
(readyState==4){<BR> <BR>
var status=xhr.status;<BR>
<BR>
if(status==200){<BR>
<BR>
var resultset =
xhr.responseText;<BR>
<BR>
if(resultset == null){<BR>
onComplete(null);<BR>
return;<BR>
}<BR>
if(onComplete){<BR>
onComplete(resultset);<BR>
resultset
= null;<BR>
}<BR> }<BR>
else{<BR>
if(onError){<BR>
onError(xhr.responseText);<BR>
}<BR>
}<BR>
<BR>
xhr.onreadystatechange = function(){};<BR>
<BR> xhr =
null;<BR> }<BR> };<BR>
<BR> var paramString=null;<BR> <BR>
if(paramNames&<SPAN class=t_tag onclick=tagshow(event)
href="tag.php?name=amp">amp</SPAN>;&<SPAN class=t_tag onclick=tagshow(event)
href="tag.php?name=amp">amp</SPAN>;paramNames.length>0){<BR>
<BR> var params = new Array();<BR>
<BR>
while(paramNames&&paramNames.length>0)<BR>{<BR>
params.push(paramNames.shift()+"="+_ToJSON(paramValues.shift()));<BR>
}<BR>
<BR> paramString =
params.join("&");<BR> <BR>
}<BR> <BR>
xhr.send(paramString);<BR>};</CODE></DIV></DIV></DIV>
<DIV id=wz><A
href="javascript:location.href='http://del.icio.us/post?&url='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title)"><IMG
title=Del.icio.us alt=Del.icio.us
src="Ajax分页查询程序 - AJAX - 4s资讯社--分享与交流.files/delicious.gif"
border=0>Del.icio.us</A> <A
href="javascript:window.open('http://shuqian.qq.com/post?title='+encodeURIComponent(document.title)+'&uri='+encodeURIComponent(document.location.href)+'&jumpback=2&noui=1','favit','width=960,height=600,left=50,top=50,toolbar=no,menubar=no,location=no,scrollbars=yes,status=yes,resizable=yes');void(0)"><IMG
style="MARGIN-RIGHT: 2px" alt=收藏到QQ书签
src="Ajax分页查询程序 - AJAX - 4s资讯社--分享与交流.files/add.gif" align=absMiddle
border=0>收藏到QQ书签</A> <A
href="javascript:location.href='http://myweb.cn.yahoo.com/popadd.html?url='+encodeURIComponent(document.location.href)+'&title='+encodeURIComponent(document.title)"><IMG
src="Ajax分页查询程序 - AJAX - 4s资讯社--分享与交流.files/yahoo.gif"
border=0>添加到雅虎收藏</A> <A
href="javascript:location.href='http://www.google.com/bookmarks/mark?op=add&bkmk='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title)"><IMG
alt=Google书签 src="Ajax分页查询程序 - AJAX - 4s资讯社--分享与交流.files/google.gif"
border=0>Google书签</A> <A title=Baidu搜藏
href='javascript:u=location.href;t=document.title;c%20=%20""%20+%20(window.getSelection%20? window.getSelection() : document.getSelection ? document.getSelection() : document.selection.createRange().text);var url="http://cang.baidu.com/do/add?it="+encodeURIComponent(t)+"&iu="+encodeURIComponent(u)+"&dc="+encodeURIComponent(c)+"&fr=ien#nw=1";window.open(url,"_blank","scrollbars=no,width=600,height=450,left=75,top=20,status=no,resizable=yes"); void 0'><IMG
alt=Baidu搜藏 src="Ajax分页查询程序 - AJAX - 4s资讯社--分享与交流.files/baidu.gif"
border=0>Baidu搜藏</A> </DIV>
<DIV class=article_recom>
<DIV class=article_recom_fix_height>
<DIV class=article_recom_title>站内相关推荐</DIV>
<DIV class=article_recom_l>
<UL><!--首页显示到第14条(小编推荐)-->
<LI><A title=Ajax分页查询程序 href="http://www.4studio.cn/www/42/2008-04/2418.html"
target=_blank>Ajax分页查询程序</A>
<LI><A title=Ajax开发框架 href="http://www.4studio.cn/www/42/2008-03/2362.html"
target=_blank>Ajax开发框架</A>
<LI><A title=AJAX的前途 href="http://www.4studio.cn/www/42/2008-03/2366.html"
target=_blank>AJAX的前途</A>
<LI><A title=AJAX实现用户注册表单检测
href="http://www.4studio.cn/www/42/2008-03/2367.html"
target=_blank>AJAX实现用户注册表单检测</A>
<LI><A title="掌握 Ajax 之操纵 DOM"
href="http://www.4studio.cn/www/42/2008-01/539.html" target=_blank>掌握 Ajax 之操纵
DOM</A> </LI></UL></DIV>
<DIV class=article_recom_r>
<UL>
<LI><A title=Ajax技术全解之一 href="http://www.4studio.cn/www/42/2008-01/537.html"
target=_blank>Ajax技术全解之一</A>
<LI><A title=Ajax技术全解之二 href="http://www.4studio.cn/www/42/2008-01/536.html"
target=_blank>Ajax技术全解之二</A>
<LI><A title=Ajax技术全解之三 href="http://www.4studio.cn/www/42/2008-01/535.html"
target=_blank>Ajax技术全解之三</A>
<LI><A title=Ajax技术全解之四 href="http://www.4studio.cn/www/42/2008-01/534.html"
target=_blank>Ajax技术全解之四</A>
<LI><A title=Ajax控件和类库简析 href="http://www.4studio.cn/www/42/2008-01/522.html"
target=_blank>Ajax控件和类库简析</A> </LI></UL></DIV></DIV></DIV>
<DIV id=comment__c></DIV>
<SCRIPT language=JavaScript
src="Ajax分页查询程序 - AJAX - 4s资讯社--分享与交流.files/xhr.js"></SCRIPT>
<SCRIPT language=JavaScript
src="Ajax分页查询程序 - AJAX - 4s资讯社--分享与交流.files/comment.js"
type=text/javascript></SCRIPT>
<SCRIPT language=javascript>
var tid = 2418;
var mid = 1;
var cid = 42;
var flag = 0;
function re_init(subjectid)
{
subject_id = subjectid;
init_message(5);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -