Using AJAX to implement non-refreshing data paging _ajax related

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.