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
相关文档:
1、在服务端加 header("Cache-Control: no-cache, must-revalidate");
2、在ajax发送请求前加上 xmlHttpRequest.setRequestHeader("If-Modified-Since","0");
3、在ajax发送请求前加上 xmlHttpRequest.setRequestHeader("Cache-Control","no-cache");
4、在 Ajax 的 URL 参数后加上 "?fresh=" + Math.rando ......
Ajax------很多程序员都喜欢玩这个东西,觉得很是高深莫测,而且越是痛苦越钟爱,我发现这是程序员的通病,好像不折磨自己不足以享受这么美好的生活,Ajax很火,确实很火,火到什么程度我已经不大清楚,在当时我学程序的那个年代它甚至超过spring,struts等等主流的框架,天哪微软和SUN都很担心,但是时间证明Ajax仅仅只是个这些程序员 ......
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 应用程序都使用请求/响应模型从服务器上获得完整的 HTML 页面。常常是点击一个按钮,等待服务器响应,再点击另一个按钮,然后再等待,这样一个反复的过程。有了 Ajax 和 XMLHttpRequest 对象,就可以使用不必让用户等待服务器响应的请求/响应模型了。本文中,Brett McLaughlin 介绍了如何创建能够适应不同浏览器的 ......
对于很多 Web 开发人员来说,只需要生成简单的请求并接收简单的响应即可;但是对于希望掌握 Ajax 的开发人员来说,必须要全面理解 HTTP 状态代码、就绪状态和 XMLHttpRequest 对象。在本文中,Brett McLaughlin 将向您介绍各种状态代码,并展示浏览器如何对其进行处理,本文还给出了在 Ajax 中使用的比较少见的 HTTP 请求。 ......