Here's a common question for y'all.
Just looking to pick your brains on ways to have a page display a static image or a div while it's waiting for the server to send back data. There may even be some server-side trickery that can be done to make my current implementation work.
What I have at the moment work while data is physically downloading to the page. I have a div that has display set to "block" and an onload event in the <body> which sets it back to display: none. This works, but only once the server has responded and started sending data.
Any idea how I could do something like that while the server is working? I attempted placing an onclick handler in all my hyperlinks to make that little div display again but it doesn't work because once the browser starts waiting for the server to respond nothing happens inside the window.
Could I do something with output buffering perhaps to send back that first bit of data even if the application is still processing some long-winded task?
"Loading" icon
Moderator: General Moderators
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
flush() and output buffering won't work too well because browsers have their own internal buffer that needs to fill up before they will display anything. I've got a script with a loading bar & to make that work, I had to output 10000 spaces to fill up the buffer (I'm sure that number can be fiddled with). So stick with what you've got - just fill up the browser buffer first.
.... unless you wanted to use AJAX somehow - that opens up more possibilities.
.... unless you wanted to use AJAX somehow - that opens up more possibilities.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.