Used to use the asp.net when using the GridView control, the control with its own paging function, although very ugly, but the function is still very powerful. Here, let's show you a more giving way--using AJAX without refreshing to get data paging directly from the server.
First, the implementation process
Note: The content is used within the server.
First, create a few files under the server's path, such as Page1.txt,page2.txt,page3.txt.
Put an array in each file, as follows:
Copy Code code as follows:
[{User: ' Blue ', pass: ' 123 '},{user: ' AAA ', pass: ' Dsfaa '},{user: ' Ares ', pass: ' 12346 '}]
Figure one page of content
Foreground HTML code:
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
Encapsulated Ajax, JavaScript code:
/*
ajax wrapper function
URL: The system to read the address of the file
fnsucc: A function, file fetch, after loading will call/
function ajax (URL, fnsucc, fnfaild)
{
//1. Create Ajax object
var oajax=null;
if (window. XMLHttpRequest)
{
oajax=new xmlhttprequest ();
}
else
{
oajax=new activexobject ("Microsoft.XMLHTTP");
}
2. Connect Server
oajax.open (' Get ', url, true);
3. Send request
oajax.send ();
4. Return of the receiving server
oajax.onreadystatechange=function ()
{
if (oajax.readystate==4)//complete
{
if ( OAJAX.STATUS==200) //Success
{
fnsucc (oajax.responsetext);
}
else
{
if (fnfaild)
fnfaild (Oajax.status);}}}
;
}
Final implementation effect:
Figure II Show effect
Second, summary
Ajax this is still a lot to try, but also a lot of practice. Pagination is a good idea, you can improve the speed of access, a good way, will be better for everyone to bring harvest.