Milktea
Milktea

Reputation: 161

Is there a way to load a particular part of a page then later load another part of the page without using JQuery and Ajax?

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

Answers (3)

Jake Feasel
Jake Feasel

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

Sune Rasmussen
Sune Rasmussen

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

Mike Christensen
Mike Christensen

Reputation: 91726

Yes, this is called "Chunking". Most frameworks and servers support this.

http://en.wikipedia.org/wiki/Chunked_transfer_encoding

Upvotes: 1

Related Questions