Ajax的无刷新分页
Ajax的无刷新分页
这里以两个文件进行代码显示一个是ajax分页实现的文件,另一个是分页类文件
文件1.ajax_page.php
<script type="text/javascript" language="javascript">
function createXMLHttp()
{
var browser=navigator.appName; //get the current browser
if(browser=="Microsoft Internet Explorer")
{
xmlHttp=new ActiveXObject("Microsoft.XMLHttp"); //if is IE
}
else xmlHttp=new XMLHttpRequest();
}
function changePage(url)
{
xmlHttp.onreadystatechange=newPage;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}
function newPage()
{
if(xmlHttp.readyState==4)
{
if(xmlHttp.status==200)
{
document.getElementById("newPage").innerHTML=xmlHttp.responseText;
}
}
}
function doPage(url)
{
var xmlHttp=false;
createXMLHttp();
document.getElementById("newPage").innerHTML="正在读取数据...";
changePage(url);
}
</script>
<style type="text/css">
#pageWay{
background-color:#b5d6e6; background-image:url("tab_19.gif"); width:100%; font-size:15px; padding:5px;
}
span{
color:red; font-weight:700;
}
.one{
width:37px; height:15px;
}
.two{
width:43px; height:15px;
}
img{
border:0px;
}
</style>
<div id="newPage">
<?php
include "database.class.php";
include "page.class.php";
$db=new database();
$data_sql="SELECT `exptime`,`realdat`,`predat` from `labrec`";
$data_res=$db->query($data_sql) or die($db->error());
$data_nums=$db->num_rows($data_res); //求出总的数据条数
if($data_nums)
{
&nbs
相关文档:
一.摘要
本系列文章将带您进入jQuery的精彩世界, 其中有很多作者具体的使用经验和解决方案, 即使你会使用jQuery也能在阅读中发现些许秘籍.
本篇文章讲解如何使用jQuery方便快捷的实现Ajax功能.统一所有开发人员使用Ajax的方式.
二.前言
Ajax让用户页面丰富起来, 增强了用户体验. 使用Ajax是所有Web开发的必修课. ......
我在上一篇文章中使用原始javascript的方式构造ajax调用,但从全局看,不仅仅代码的阅读性比较低而且隐藏发生错误的可能,比如在页面加载时就改变dom结构,还要时刻关注浏览器的兼容性,而使用jQuery我们将不存在类似的问题,代码的可读性也显著提高,代码量小,下面是jQuery版本的js部分代码,希望能够对读者 ......
多数 Web 应用程序都使用请求/响应模型从服务器上获得完整的 HTML 页面。常常是点击一个按钮,等待服务器响应,再点击另一个按钮,然后再等待,这样一个反复的过程。有了 Ajax 和 XMLHttpRequest 对象,就可以使用不必让用户等待服务器响应的请求/响应模型了。本文中,Brett McLaughlin 介绍了如何创建能够适应不同浏览器的 ......
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<script type="text/javascript" src="http://www.google.com/jsapi"></script> ......