Copy codeThe Code is as follows:
<! DOCTYPE html>
<Html>
<Head>
<Title> ajax paging </title>
<Script src = "http://code.jquery.com/jquery-1.11.0.min.js"> </script>
<Script>
Function loadXMLDoc ($ url)
{
Var xmlhttp;
If (window. XMLHttpRequest)
{// Code for IE7 +, Firefox, Chrome, Opera, Safari
Xmlhttp = new XMLHttpRequest ();
}
Else
{// Code for IE6, IE5
Xmlhttp = new ActiveXObject ("Microsoft. XMLHTTP ");
}
Xmlhttp. onreadystatechange = function ()
{
If (xmlhttp. readyState = 4 & xmlhttp. status = 200)
{
Var $ data = $ ('<div>' + xmlhttp. responseText + '</div> ');
// Alert ($ ("# updateId", using data=.html ());
// Document. getElementById ("myDiv"). innerHTML = xmlhttp. responseText;
$ ("# UpdateId"). replaceWith ($ ("# updateId", $ data ));
}
}
Xmlhttp. open ("GET", $ url, true );
Xmlhttp. send ();
}
</Script>
</Head>
<Body>
<Table id = "updateId">
<Tr> <td> id </td> <td> title </td> <td> time </td> </tr>
<? Php if (isset ($ _ GET ['P']) & $ _ GET ['P'] = 2):?>
<Tr> <td> 2 </td> <td> 222 </td> <td> 222 </td> </tr>
<Tr> <td> 2 </td> <td> 222 </td> <td> 222 </td> </tr>
<? Php else:?>
<Tr> <td> 1 </td> <td> 111 </td> <td> 111 </td> </tr>
<Tr> <td> 1 </td> <td> 111 </td> <td> 111 </td> </tr>
<? Php endif;?>
</Table>
<Div> <a href = "javascript:;" onclick = "loadXMLDoc ('? P = 1') "> 1 </a> <a href =" javascript:; "onclick =" loadXMLDoc ('? P = 2') "> 2 </a> </div>
</Body>
</Html>