<? Php
Header ("Content-Type: text/html; charset = UTF-8 ");
Function AjaxPage ($ Total, $ ListNub, $ CurrentPage, $ Url, $ AjaxAction, $ HalfPer = '', $ ViewId = '')
{
// Calculate the total number of pages
$ TotalPage = @ ceil ($ Total/$ ListNub );
$ Total = $ totalPage-1;
$ Re = "";
// Echo $ CurrentPage;
$ Re. = ($ CurrentPage> 0)
?
"<Td> <
Href = \ "javascript: $ AjaxAction ('$ Url = 0',' $ ViewId ') \ "\"> homepage </a> </td> \ n <td> <
Href = \ "javascript: $ AjaxAction ('". $ Url. "= ". ($ CurrentPage-1 ). "',' $ viewid') \" \ "> previous page </a> </td> \ n"
:
"<Td> homepage </td> \ n <td> previous page </td> \ n ";
For ($ I =
$ CurrentPage-$ HalfPer, $ I> 0 | $ I = 0, $ j =
$ CurrentPage + $ HalfPer, $ j <$ totalPage | $ j = $ totalPage; $ I <$ j; $ I ++
)
{
$ Re. = $ I ==$ CurrentPage
?
"<Td> <B class = currentPage> [". ($ I + 1 ).
"] </B> </td> \ n"
: "<Td> <
Href = \ "javascript: $ AjaxAction ('$ Url = $ I', '$ viewid') \"> ". ($ I + 1 ).
"</A> </td> \ n ";
}
$ Re. = ($ CurrentPage <$ total
)
? "<Td> <
Href = \ "javascript: $ AjaxAction ('". $ Url. "= ". ($ CurrentPage + 1 ). "',' $ viewid') \" \ "> next page </a> </td> \ n <td> <
Href = \ "javascript: $ AjaxAction ('". $ Url. "= ". ($ total ). "',' $ viewid') \" \ "> last page </a> \ n </td>"
:
"<Td> next page </td> \ n <td> last page </td> \ n ";
$ Re = "<table
Style = text-align: center> <tr> $ re </tr> </table> ";
Return
$ Re;
}
// The total number of pages, passed page variable-the number of pages before and after the current page url address
$ Page = $ _ GET ['page'];
// Echo
Page ('10', $ page, 'index. php? Page ', '2 ');
?>
<Div id = "nike">
<? Php
Echo
AjaxPage (, $ page, 'rand. php? Page ', 'ajaxaction', '2', 'nike ');
?>
</Div>
<Script type = "text/javascript" language = "javascript">
Var
Http_request = false;
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 ('the XMLHttpRequest object cannot be created! ');
Return
False;
}
Http_request.onreadystatechange = function
() {Likeakak (htmlid);} // processRequest (htmlid)
Http_request.open ('get ',
Url, true );
Http_request.send (null );
}
// Process the returned information
Function processRequest (htmlid ){
If
(Http_request.readyState = 1)
{
Document. getElementById (htmlid). innerHTML = "downloading ...";
}
If
(Http_request.readyState = 4 ){
If (http_request.status = 200)
{
Document. getElementById (htmlid). innerHTML = http_request.responseText;
}
Else
{
Alert ('request exception ');
}
}
}
// Process the returned information
Function
Likeakak (htmlid)
{
If (http_request.readyState = 1)
{
Document. getElementById (htmlid). innerHTML = "downloading ...";
}
If
(Http_request.readyState = 4 ){
If (http_request.status = 200)
{
Document. getElementById (htmlid). innerHTML = http_request.responseText;
}
Else
{
Alert ('request exception ');
}
}
}
Function
Ajaxaction (url, viewid)
{
Send_request (url, viewid );
}
// Customize the call Function
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]);
}
</Script>