Problem with loading a picture to resolve a short blank page in an AJAX data load (recommended) _ajax related

Source: Internet
Author: User
Tags blank page

When you use Ajax to get data asynchronously in a project, sometimes the page always appears blank because of data problems or network problems, and now it is used to load pictures to transition this state:

<script> $ (function () {$.ajax ({URL: ',///provide interface file address link dataType: ' JSON ', type: ' POST ', Beforesend:function () {$ (' #loading '). HTML ("<p style=\" color: #999; font-size:14px\ "> Load, please ......</p> later")//Send the picture before the data is sent
        Error:function (msg) {//Data read failure display Znodes=data.responsejson;
      Alert ("Sorry, data acquisition failed, please contact admin");  Success:function (msg) {//Data reads successfully and displays the list of data $ (' #loading '). fadeout (1000);
        Picture display time; var ul = ""; for (var i= 0;i<msg.legth;i++) {//Data list row number ul = "<li class= ' list ' ><a href= ' php/phparticle.php?art=" +ms g[i][' id ']+ ' class= ' widget-list-link ' > ' + msg[i][' title ']+ ' <i class= ' more-mark ' > ' + ' >> ' + ' </i>
        </a></li> ";
      $ ("#list"). HTML (UL);
      Error:function () {////Console.log ("link Error") is displayed when failure occurs;
  }
    });
}); </script> 

Data is displayed in load state

The above is a small set to introduce the use of loading pictures to solve in the AJAX data loading page of the short blank problem (recommended), I hope to help you, if you have any questions please give me a message, small series will promptly reply to everyone. Here also thank you very much for the cloud Habitat Community website support!

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.