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!