Reputation: 161
For this project, I have to have it so that the page loads while making queries the database, but even if the query hasn't finished loading, I want the page to show up with and wait for the query to be done. This way, the page doesn't just sit there while the user is wondering what's going on. I know this is possible with Ajax, but I was wondering if there was a way to do without it.
I'm using MVC3 and IIS 7.
Upvotes: 1
Views: 488
Reputation: 16945
You could always load a wrapping page with plain HTML, then embed the call to the code which performs the database function within an iFrame. Pretty ghetto means of doing back-and-forth stuff, but it should work.
edit
Besides iFrames, you could also have a
<script src="pathToSlowCode/"></script>
... tag embedded at the end of your wrapping page. When it finally loads, you'll have access to the javascript returned by that page to use to handle the response.
Upvotes: 1
Reputation: 954
If you're using PHP, you could just flush the output buffer when you've produced all but the query part of the page on the server, so that the client receives that part of the page (i.e. the header and the top of the content).
Then just add the rest when the query has finished, and then flush the buffer again. You may also need to add the header "Transfer-Encoding: chunked", but I'm not sure.
Upvotes: 0
Reputation: 91726
Yes, this is called "Chunking". Most frameworks and servers support this.
http://en.wikipedia.org/wiki/Chunked_transfer_encoding
Upvotes: 1