6

I have 2 pages, when the second page load in first page, the JavaScript of that pages run after all the JavaScript and load very slowly. I wrote the below code to show the spinner till the second page load completely. But the spinner doesn't s work. Here is my code:

<script>
    $('.tourajaxi').html('<i class="fa fa-spinner fa-pulse fa-3x fa-fw" ></i><span class="sr-only">Loading ...</span>');
     $(window).load(function()  {
    $('.tourajaxi').load('/toursajax.bc?gid=325');
    });
    </script>
user3678528
  • 1,741
  • 2
  • 18
  • 24
inaz
  • 1,755
  • 4
  • 20
  • 41
  • Have you tried logging `$('.tourajaxi')`? Possibility is that you DOM is not rendered. Try showing spinner on `$(document).ready()` – Rajesh Aug 28 '16 at 06:05
  • @inaz hi may be you have larger data and that because you are loading whole page with $.load() method so i might be little slow – Himesh Aadeshara Aug 28 '16 at 06:09
  • when i use document.ready() the css and html of second page load.but javascripts not rendered, and load very slowly. i want to run all of my second page at the same time – inaz Aug 28 '16 at 06:09
  • @inaz I guess then the real issue is scripts not getting rendered. You can refer following post for more reference: http://stackoverflow.com/questions/889967/jquery-load-call-doesnt-execute-javascript-in-loaded-html-file – Rajesh Aug 28 '16 at 06:15

1 Answers1

1

A guess, since you haven't included any HTML:

Your script is in the <head> of the document, and tries to apply HTML to the element "tourajaxi", but that element does not exist until the rest of the document is loaded.

Kae Verens
  • 4,076
  • 3
  • 21
  • 41