Re: Iconize weather info and something else
Brought to you by:
iridium
From: Martin G. <gim...@gi...> - 2002-02-10 15:00:38
|
"Ray van Beek" <r_v...@ho...> writes: > The problem with the loading part in the first part of the page and > the reconstruction of the "Loading..." text is that the server does > not return a page before the entire page is processed, at least that > is what i see. Maybe with very large pages, the browser does not > wait for the end and starts displaying before it has received the > end. I've actually got something working - take a look at http://www.gimpster.com/php/phpweather/demo2.php?sleep=5 The idea is this: o Instead of calling print_pretty_metar(), we call some other function. This function will write 'Please wait...' in a <span> tag with the id attribute set accordingly. The ICAO is saved in an array o We call flush() after writing 'Please wait...'. This will push the content from the server toward the client. This will (hopefully) make the browser start rendering the page, so that the user see the 'Please wait...' text. The browser wont start rendering the page, if it doesn't know the size of the box containing the 'Please wait...' text. o At the very end of the page, we go through the stored ICAOs. For each stored ICAO, we retrieve the METAR, and retrieve the pretty-print. o We then write some JavaScript that will replace the text in the <span> tags inserted earlier in the text. o We call flush() again, so that the JavaScript is sent to the client, and so that the browser will execute it. o We repeat this process until we have made scripts for all the stored ICAOs. It works in my browser (which is Mozilla 0.9.7). What I've done is just a quick hack - we should probably restructure a couple of things to implement this properly. You can see the code here: http://www.gimpster.com/showsource.php?file=/php/phpweather/demo2.php > Martin, you're right. Generating a new page from js which contains php > is not parsed at the server but processed in the browser directly. Right... -- Martin Geisler My GnuPG Key: 0xF7F6B57B See my homepage at http://www.gimpster.com/ for: PHP Weather => Shows the current weather on your webpage. PHP Shell => A telnet-connection (almost :-) in a PHP page. |