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;
相关文档:
多数 Web 应用程序都使用请求/响应模型从服务器上获得完整的 HTML 页面。常常是点击一个按钮,等待服务器响应,再点击另一个按钮,然后再等待,这样一个反复的过程。有了 Ajax 和 XMLHttpRequest 对象,就可以使用不必让用户等待服务器响应的请求/响应模型了。本文中,Brett McLaughlin 介绍了如何创建能够适应不同浏览器的 ......
ajax就是javascript 因为以前javascript没有httpXMLrequest对象,从IE5.0之后出现,说白了ajax就是可以用javascript向服务器发送请求,并且能接收服务返回的内容,写ajax程序只要写出一个发送函数和一个接收服务员返回的函数即可,在服务器程序中可以返回字符串也可以返回xml,实例程序http://xsuo.javaeye.com/blog/578637 ......
Ajax的无刷新分页
这里以两个文件进行代码显示一个是ajax分页实现的文件,另一个是分页类文件
文件1.ajax_page.php
<script type="text/javascript" language="javascript">
function createXMLHttp()
{
var browser=navigator.appName; //get the current browser
......
Java代码
@Override
protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object cmd,
BindException ex) {
&nb ......
在Web开发程序中,往往由于种种原因,客户会多次操作页面导致数据冗余或不一致, 在ASP.NET AJAX出现之前可以通过对__dopostback()的调用等方法也可以防止页面多次提交。
在ASP.NET AJAX中的页面客户端中有一个叫onInitializeRequest的事件,它在页面初始化之前触发,可以对页面的提交事件进行控制,并且可以调用该事件参 ......