The cleanest solution I've seen to this problem is the following:
- Create two divs on your page. One contains a GIF-89 that has some neat status indicator that repeats. The second contains your data and starts out as display: none;
- Immediately render the first div and the beginning of the second div. This way, your user sees something.
- As you get results, render them right away so as to keep the connection alive.
- After you finish rendering, hide the first and show the second div.
My criteria for good software:
- Does it work?
- Can someone else come in, make a change, and be reasonably certain no bugs were introduced?