/    Sign up×
Community /Pin to ProfileBookmark

Control Load Order? of Site

My php data that I put inside the html table is

[code]<?php
include(“table/table.php”);
?>[/code]

that grabs the data that will go into my html table.

Well the problem I’m having is that the rest of the table with stuff under the table won’t load till the php is done being processed.
This makes my site look weird for 4 seconds and is the reason why I want to load the php content last.

Is there a way to do this with php or javascript?

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@scragarMar 17.2011 — You can do this in a few ways, none are perfect.

Using javascript makes the code harder to debug and doesn't work for users with javascript disabled.

Using frames/iframes are always an ugly solution to any problem and run the problem of needing multiple pages for a single pages contents.

Examples:

JS&lt;script type="text/javascript"&gt;
window.onload = function(){

var ajax = window.XMLHttpRequest? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
var tgh = document.getElementById('tableGoesHere');

xmlhttp.open("GET", "table.php" ,false);
xmlhttp.send();

if(ajax.status==200)
tgh.innerHTML = ajax.responseText;
else
tgh.innerHTML = "ERROR loading table";
}
&lt;/script&gt;

....

&lt;div id="tableGoesHere"&gt;&lt;/div&gt;

iFrame&lt;iframe src="table.php"&gt;Text to display if iframe is disabled for some reason&lt;/iframe&gt;

Please note that as much as I hate using javascript for things where it's not needed frames are significantly worse.
×

Success!

Help @iosys spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.15,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...