<!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>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>php教程 ajax分页程序代码</title>
<script language="网页特效" type="text/javascript">
function $()
{
var elements = new array();
for (var i = 0; i < arguments.length; i++)
{
var element = arguments[i];
if (typeof element == 'string')
element = document.getelementbyid(element);
if (arguments.length == 1)
return element;
elements.push(element);
}
return elements;
}
var xmlhttp
function pagination(page)
{
xmlhttp=getxmlhttpobject();
if (xmlhttp==null)
{
alert ("your browser does not support ajax!");
return;
}
var url="server.php";
url = url+"?starting="+page;
url=url+"&sid="+math.random();
xmlhttp.onreadystatechange=statechanged;
xmlhttp.open("get",url,true);
xmlhttp.send(null);
}
function statechanged()
{
/****
0 - (未初始化)还没有调用send()方法
1 - (载入)已调用send()方法,正在发送请求
2 - (载入完成)send()方法执行完成,已经接收到全部响应内容
3 - (交互)正在解析响应内容
4 - (完成)响应内容解析完成,可以在客户端调用了
***/
if (xmlhttp.readystate==4)
{
$("page_contents").innerhtml=xmlhttp.responsetext;
}
}
function getxmlhttpobject()
{
var xmlhttp=null;
try
{
// firefox, opera 8.0+, safari
xmlhttp=new xmlhttprequest();
}
catch (e)
{
// internet explorer
try
{
xmlhttp=new activexobject("msxml2.xmlhttp");
}
catch (e)
{
xmlhttp=new activexobject("microsoft.xmlhttp");
}
}
return xmlhttp;
}
</script>
<link rel="stylesheet" type="text/css教程" href="style.css" />
</head>
<body>
<div id="page_contents">
|