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 介绍了如何创建能够适应不同浏览器的 ......
在
vs2008为asp.net ajax添加js智能感知
今天找了好久,终于搞清楚了,scriptManager控件支持js智能感知,而从其继承的toolkitScriptManager不支持。至少在
vs2008b2中是这样。
要在js文件中添加asp.net ajax的js智能感知(与scriptManager控件无关),在js文件的开头添加这样一行即可:
//
/<referen ......
一、ajax的入门
1、XMLHttpRequest对象的使用(使用XMLHttpRequest解析xml文件)
onreadystatechange
指定当readyState属性改变时的事件处理句柄
open()
创建一个新的http请求,并指定此请求的方法、URL等信息
send()
发送请求到http服务器并接收回应
readyState
&nb ......
<mce:script type="text/javascript" language="javascript"><!--
var http_request = false;
function makePOSTRequest(url, parameters) {
http_request = false;
if (window.XMLHttpRequest) { // Mozilla, Safari,...
http_request = new XMLHttpRequest();
if (ht ......
<html>
<body>
<script language="JavaScript">
var req = null;
function test() {
var province = document.all("province").value;
req = new ActiveXObject("Microsoft.XMLHTTP ......