I want to add a PHP page with custom ajax loading design as ajax loader to website pages. I'm currently using very simple code in below and I need your help to guide me how to add my PHP page in this loading screen code.
Here is JavaScript code:
window.addEventListener("load", function(){
var load_screen = document.getElementById("load_screen");
document.body.removeChild(load_screen);
});
and
<div id="load_screen"> <div id="loading">loading document </div></div>
The above code currently is working well, but it's only text, I need to show ajax.php
instead of that loading screen text.
actually I did like this, but both pages load together, I mean ajax.php
and main page will load together, it should be ajax.php
first then after main page will load, but I don't know why both of them load together, what is the wrong with my code?
<div id="load_screen"> <div id="loading"><?php include "ajax.php"; ?></div></div>
1: How can I add ajax.php instead of loading document text ?
2: How to add timer for this loading?
3: Why ajax.php and main page (both) load together? It should be ajax.php load first then main page will load. so how to solve it?
Thank you