Я пытаюсь найти правильный синтаксис кода для вставки "загрузки GIF", пока функция загрузки работает, вставляя информацию на мою страницу ...
<script> ('#myinfo').load('/data/myinfo.html'); </script>
Должен ли я положить загрузочный GIF внутри?
<script> //delay script until after the page has been parsed into the DOM $(document).ready(function(){ //get a reference to whatever holds the gif, or the gif itself var $loadingGif = $(selectorForLoadingGif); //show the gif before the load starts $loadingGif.show(); //load the other info $('#myinfo').load('/data/myinfo.html', function(){ //this method executes after the load finishes //hide the loading gif $loadingGif.hide(); }); }); </script>
Per https://www.w3schools.com/howto/howto_css_loader.asp, это двухэтапный процесс без JS:
1.Добавьте этот HTML-код туда, где вы хотите прядильщик:
2.Добавьте этот CSS, чтобы сделать фактический счетчик:
.loader { border: 16px solid #f3f3f3; /* Light grey */ border-top: 16px solid #3498db; /* Blue */ border-radius: 50%; width: 120px; height: 120px; animation: spin 2s linear infinite; } @keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }