Js 分页类 (适合Ajax分页用)
调用方法如下:
var p = new Pager(5, 10);
p.init('页码所在的容器ID', dataOp);
function dataOp() {
// ajax数据操作
SendContent("/Admin/TopicService.asmx/GetTopicList?currentPageIndex=" + p.currentPage + "&pageSize=" + p.pageSize, "GET", "", ajax postback method);
}
JS代码如下:
// ==============================================================================
// Created by Bndy at 2010/3/18
// Copyright (c) 2010 ahdzlc, All rights reserved.
//
// * * * * * * * * * * * * * * * *
// * Q Q : 8 1 7 9 5 7 0 5 *
// * M S N : bndy533@msn.com *
// * Email : bndy533@163.com *
// * * * * * * * * * * * * * * * *
//
// ------------------------------------------------------------------------------
// JS 分页函数
// 适合Ajax分页时使用
// ==============================================================================
var pager;
var handler;
var Pager = function(totalRecordCount, pageSize) {
this.pageSize = pageSize;
this.currentPage = 1;
this.totalPageCount = totalRecordCount % pageSize != 0 ? Math.floor(totalRecordCount / pageSize) + 1 : Math.floor(totalRecordCount / pageSize);
var ele;
this.getBeginPageNum = function() {
if (this.pageSize > this.totalPageCount) {
return 1;
}
if (this.currentPage > this.totalPageCount) {
return this.totalPageCount - this.pageSize + 1;
}
else {
return Math.floor((this.currentPage - 1) / this.pageSize) * this.pageSize + 1;
}
};
this.getEndPageNum = function() {
var x = Math.floor((this.currentPage - 1) / this.pageSize) * this.pageSize + this.pageSize;
if (this.pageSize > this.totalPageCount || this.currentPage > this.totalPageCount || x > this.totalPageCount) {
return this.totalPageCount;
相关文档:
What is AJAX
This section is for those who have no idea what AJAX is. If you don’t fall into this category, feel free to skip to the next section.
AJAX stands for asynchronous JavaScript and XML. If you see another term XHR, which is shorthand for XML HTTP request, it’s the same thing. ......
对于很多 Web 开发人员来说,只需要生成简单的请求并接收简单的响应即可;但是对于希望掌握 Ajax 的开发人员来说,必须要全面理解 HTTP 状态代码、就绪状态和 XMLHttpRequest 对象。在本文中,Brett McLaughlin 将向您介绍各种状态代码,并展示浏览器如何对其进行处理,本文还给出了在 Ajax 中使用的比较少见的 HTTP 请求。 ......
ajax.open方法中,第3个参数是设同步或者异步。prototype等js类库一般都默认为异步,即设为true。
先说下同步的
情况下,js会等待请求返回,获取status。不需要onreadystatechange事件处理函数。
而异步则需要
onreadystatechange事件处理,且值为4再正确处理下面的内容
......
Ajax的无刷新分页
这里以两个文件进行代码显示一个是ajax分页实现的文件,另一个是分页类文件
文件1.ajax_page.php
<script type="text/javascript" language="javascript">
function createXMLHttp()
{
var browser=navigator.appName; //get the current browser
......
在Web开发程序中,往往由于种种原因,客户会多次操作页面导致数据冗余或不一致, 在ASP.NET AJAX出现之前可以通过对__dopostback()的调用等方法也可以防止页面多次提交。
在ASP.NET AJAX中的页面客户端中有一个叫onInitializeRequest的事件,它在页面初始化之前触发,可以对页面的提交事件进行控制,并且可以调用该事件参 ......