undefinedfix
Sign in

How can jQuery load a loading image first and then display the content?

AmericanGeek edited in Sat, 09 Jan 2021

Because the chart effect of ecart needs to show the loading effect when loading. Because several tab pages are switched, and all the data is returned in one request, the showloading method of ecart itself can't be used. So how can jQuery realize the effect of image loading and then disappearing to display the content

2 Replies
Amer
commented on Sat, 09 Jan 2021

Ecarts itself is used to display data, so the effect you need can be realized. I just did a big data project that ecarts did before

  • First of all, you can find a loading image or use CSS to draw. Anyway, it's a mask layer Z-index to cover the content below. CSS drawing is a better way. You can go to jQuery plug-in library to find a lot of loading
  • Then, after doing this well, put it in the required position of the page, and then get the data, and use ajax to get the background interface
  • Finally, after the success, set the loading hidden in the callback function, that is, the success function
Hugo
commented on Sat, 09 Jan 2021

The promise of jQuery should be available. Please refer to promise

You can hide the content and display the image before loading, and then display the content after successfully closing the image. $. When can also wait for multiple Ajax to load and complete processing together, most of which are very useful when loading for the first time

lock This question has been locked and the reply function has been disabled.