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>
There are two different types of issues that can cause admin-ajax. php slow server responses. The first is a backend CPU issue and the second is more of a frontend issue where you will notice third party plugins polling this file in your website speed tests.
In my app, there are a lot of ajax calls. A user may do 50 ajax calls per session, so speed is very important. The ajax call queries the database and returns a list of records.
Javascript provides client-side support whereas AJAX provides server-side support by exchanging data with the server. Javascript is applicable when there is an HTML and AJAX functionality that takes data using XMLHttpRequest. Javascript is a well-known programming language whereas AJAX is not a programming language.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With