Zac Webb
Zac Webb

Reputation: 663

How do I load a PHP page after the page has fully loaded?

I am relatively new to working with PHP and more specifically JQuery, so please excuse my lack of knowledge.

I am trying to load a small html table that has php information that I have queried game servers for like so.

Except... this creates quite a large loading time for the page, and I was wondering if there was a way to load the html page, display a "Loading..." sort of text and then load the PHP table from a separate file. My PHP/HTML for the table can be found here.

So to sum up, If possible, I would like a page that says "Loading..." (or something of the sort) and then once the entire HTML page has been loaded, the table of servers to appear.
I hope that I have provided all relevant information and if anything more is required please ask below, as any help would be appreciated! Again, please excuse my lack of knowledge as I am relatively new to all of this!
Thanks in advance!

Upvotes: 1

Views: 8058

Answers (2)

Thelt
Thelt

Reputation: 81

Create another php file "yourTableFile.php" with, by example

<table>
<?php
    foreach ($toto as $tutu)
        echo "<tr><td>" . $tutu . "</td></tr>";   
?>
</table>

And in your first page put the script

<script>
$(function() {
    $('#mySlowTable').load("yourTableFile.php");
});
</script>

then, where you want to show it :

<div id="mySlowTable">
    Your loading image here
</div>

Upvotes: 3

Marek
Marek

Reputation: 7433

In the main page:

<div id="theTable">Loading...</div>

$(function() { $("#theTable).load("url/to/table.php"); });

Upvotes: 1

Related Questions