ajax实现无刷新分页(php)
前端之家收集整理的这篇文章主要介绍了
ajax实现无刷新分页(php),
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
<div class="codetitle"><a style="CURSOR: pointer" data="70690" class="copybut" id="copybut70690" onclick="doCopy('code70690')"> 代码如下:
<div class="codebody" id="code70690">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "
http://www.w3.org/TR/html4/loose.dtd">
投票结果 <script type="text/javascript">
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;
}
function checkajax(){
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
{
alert ("您的浏览器
不支持AJAX!");
return ;
}else
{
return xmlHttp;
}
}
function preshow(){
ajaxobj = checkajax();
var url = "page.
PHP?page=1";
ajaxobj.onreadystatechange=stateChanged;
ajaxobj.open("GET",url,true);
ajaxobj.send(null);
}
function showHint1(str)
{
ajaxobj = checkajax();
document.getElementById("msg").innerHTML="正在读取数据……";
var url = str;
ajaxobj.onreadystatechange=stateChanged;
ajaxobj.open("GET",true);
ajaxobj.send(null);
}
function showHint2(str)
{
ajaxobj=checkajax();
document.getElementById("msg").innerHTML="正在读取数据……";
var url = str;
ajaxobj.onreadystatechange=stateChanged;
ajaxobj.open("GET",true);
ajaxobj.send(null);
}
function showHint3(str)
{
ajaxobj=checkajax();
document.getElementById("msg").innerHTML="正在读取数据……";
var url = str;
ajaxobj.onreadystatechange=stateChanged;
ajaxobj.open("GET",true);
ajaxobj.send(null);
}
function showHint4(str)
{document.getElementById("msg").style.display="none";
ajaxobj=checkajax();
document.getElementById("msg").innerHTML="正在读取数据……";
var url = str;
ajaxobj.onreadystatechange=stateChanged;
ajaxobj.open("GET",true);
ajaxobj.send(null);
}
function stateChanged()
{
if (xmlHttp.readyState==4)
{
document.getElementById("message").innerHTML=xmlHttp.responseText;
}
}
<body onload="preshow()">
<div id="wrapper">
用户留言如下:
<div id="message">