I’m developing something at the moment which uses a Flickr API call to dynamically generate some inline images related to the content. There is a noticeable delay in getting this info, though.
While I’m waiting for the images to come from Flickr and for the HTML to be generated and written, I’d like the page content up to that point to be rendered … then have that pause … and then continue.
I’ve tried placing the PHP that gets the Flickr stuff right at the end of the page, with the thought that I can use jQuery to them move it back up in to the appropriate place on the page - my thinking - get it last, so I can put the rest of the page up first.
I wondered if flush() was the answer and tried experimenting, but having tried a number of variations on that, none of it works. In all cases I get a completely blank page (just the <title> in the browser showing), no source code if I do a View Source until the Flickr stuff is done … and then BANG! All loaded in one go. Not good.
So, I’d appreciate some thoughts. Have I misunderstood the flush() method, perhaps?
I have HTML with include statements through the page. Mixture of HTML and embedded <? echo ?> statements. I think this is the reason why flush() isn’t working, right?
I’m no PHP expert - I know enough to get by - so if you have an idea or two, please bear this in mind.
One thought I had:
- move all PHP logic to separate file
- load the page, nice ‘n’ quick
- load the PHP Flickr file after using AJAX (via jQuery).
This should stop the blank page issue. But is it the best way?
Thanks for your advice.