Ajax javascript loads very slowly

I have 2 pages, when loading the second page on the first page, the JavaScript of these pages starts after all JavaScript and loads very slowly. I wrote the code below to show the counter until the second page is fully loaded. But the counter does not 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> 
+6
source share
1 answer

Guess since you did not specify any HTML code:

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

+1
source

All Articles