搜尋
首頁php教程php手册ajax无刷新分页,支持id定位

ajax无刷新分页,支持id定位

Jun 13, 2016 am 10:35 AM
ajaxcharsetheaderhtmlphptext分頁重新整理定位支援

Header("Content-Type:text/html; charset=utf-8");
// AK QQ:42220796
// 总数 单页条数 当前页 点击后的url地址get 应用的js函数  显示几个  显示的地址
function AjaxPage($Total,$ListNub,$CurrentPage,$Url,$AjaxAction,$HalfPer=,$ViewId=)
{
//计算总页数
$totalPage = @ceil($Total/$ListNub);
$total=$totalPage-1;
$re="";

//echo $CurrentPage;
$re .= ( $CurrentPage > 0 )
?
"

href="javascript:$AjaxAction($Url=0,$ViewId)"">首页 href="javascript:$AjaxAction(".$Url."=".($CurrentPage-1).",$ViewId)"">上一页 "
:
"首页 上一页 ";
for ( $i =
$CurrentPage - $HalfPer,$i > 0 || $i = 0 ,     $j =
$CurrentPage + $HalfPer, $j )
{
  $re .= $i == $CurrentPage
  ?
"[" . ( $i + 1 ) .
"]
"
  : "href="javascript:$AjaxAction($Url=$i,$ViewId)">" . ( $i + 1 ) .
"
";
}
$re .= ( $CurrentPage )
? "href="javascript:$AjaxAction(".$Url."=".($CurrentPage+1).",$ViewId)"">下一页 href="javascript:$AjaxAction(".$Url."=".($total).",$ViewId)"">尾页 "
:
"下一页 尾页 ";
$re="style=text-align:center>$re
";
return
$re;

}
//总页数,传递的页面变量-当前页 url地址 前后各多少页
$page = $_GET[page];
//echo
page(10,$page,index.php?page,2);


?>


echo
AjaxPage(200,20,$page,rand.php?page,ajaxaction,2,nike);
?>


function send_request(url,htmlid) {
http_request =
false;
if (window.XMLHttpRequest) {
  http_request = new
XMLHttpRequest();
  if (http_request.overrideMimeType)
{
   http_request.overrideMimeType(text/xml);
  }
}
else if (window.ActiveXObject) {
  try
{
   http_request = new
ActiveXObject("Msxml2.XMLHTTP");
  } catch (e)
{
   try {
    http_request = new
ActiveXObject("Microsoft.XMLHTTP");
   } catch (e)
{}
  }
}
if (!http_request)
{
  alert(不能创建 XMLHttpRequest 对象!);
  return
false;
}
http_request.onreadystatechange = function
(){likeakak(htmlid);}//processRequest(htmlid)
http_request.open(GET,
url, true);
http_request.send(null);

}

//处理返回信息
function processRequest(htmlid) {
if
(http_request.readyState == 1)
{
  document.getElementById(htmlid).innerHTML="下载中...";
}
if
(http_request.readyState == 4) {
  if (http_request.status == 200)
{
   document.getElementById(htmlid).innerHTML=http_request.responseText;
  }
else
{
   alert(请求异常);
  }
}
}
//处理返回信息
function
likeakak(htmlid)
{
if (http_request.readyState == 1)
{
  document.getElementById(htmlid).innerHTML="下载中...";
}
if
(http_request.readyState == 4) {
  if (http_request.status == 200)
{
   document.getElementById(htmlid).innerHTML=http_request.responseText;
  }
else
{
   alert(请求异常);
  }
}
}
function
ajaxaction(url,viewid)
{
send_request(url,viewid);
}

//自定义调用函数
function elist(id)
{
var inputarray = new
Array();

inputarray[1] = aaa;
inputarray[2] =
bbb;
inputarray[3] = ccc;
inputarray[4] =
ddd;
inputarray[5] = eee;

send_request(ajax.php?do=ajax&sort=+id,inputarray[id]);

}

陳述
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn

熱AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool

Undress AI Tool

免費脫衣圖片

Clothoff.io

Clothoff.io

AI脫衣器

Video Face Swap

Video Face Swap

使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱工具

mPDF

mPDF

mPDF是一個PHP庫,可以從UTF-8編碼的HTML產生PDF檔案。原作者Ian Back編寫mPDF以從他的網站上「即時」輸出PDF文件,並處理不同的語言。與原始腳本如HTML2FPDF相比,它的速度較慢,並且在使用Unicode字體時產生的檔案較大,但支援CSS樣式等,並進行了大量增強。支援幾乎所有語言,包括RTL(阿拉伯語和希伯來語)和CJK(中日韓)。支援嵌套的區塊級元素(如P、DIV),

VSCode Windows 64位元 下載

VSCode Windows 64位元 下載

微軟推出的免費、功能強大的一款IDE編輯器

SublimeText3漢化版

SublimeText3漢化版

中文版,非常好用

禪工作室 13.0.1

禪工作室 13.0.1

強大的PHP整合開發環境

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

強大的PHP整合開發環境