Loading images solves the problem of temporary blank pages during Ajax data loading (recommended ),

Source: Internet
Author: User

Loading images solves the problem of temporary blank pages during Ajax data loading (recommended ),

After obtaining data asynchronously using ajax in a project, the page is always blank due to data problems or network problems. Now, this status is transitioned by loading images:

<Script> $ (function () {$. ajax ({url: '', // provide interface file address link ype: 'json', type: 'post', beforeSend: function () {detail ('{loading'{.html (" <p style = \" color: #999; font-size: 14px \ "> loading, please wait ...... </P> ") // load the image first when the data is sent}, error: function (msg) {// zNodes = data is displayed when data Reading fails. responseJson; alert ("sorry, data acquisition failed, please contact the Administrator") ;}, success: function (msg) {// The data is read successfully and the data list is displayed $ ('# loading '). fadeOut (1000); // The image display time; var ul = ""; for (var I = 0; I <msg. legth; I ++) {// number of rows in the data list ul + = "<li class = 'LIST'> <a href = 'php/phpArticle. php? Art = "+ msg [I] ['id'] +" 'class = 'widget-list-link'> "+ msg [I] ['title'] +" <I class = 'more-mark'> "+"> "+" </I> </a> </li> ";} $ ("# list" cmd.html (ul) ;}, error: function () {// The console is displayed when a failure occurs. log ("Link error") ;}};}); </script>

Display Data in loading status

The above section describes how to use images to solve the problem of temporary blank pages during Ajax data loading (recommended). I hope it will help you, if you have any questions, please leave a message and the editor will reply to you in time. Thank you very much for your support for the help House website!

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.