This is the third part of my four-part series, "Active Client Pages, An Ajax Approach." In this part I illustrate the Ajax approach with a simple example, complete with code. Be sure to read the first two parts; they will help you understand what I'm trying to accomplish here, though the first part of this article does include a quick summary.
With the Ajax approach to ACP, the Back button of the browser is not enabled, no matter how many pages you display. This is because no window is changed. If you click the browser Refresh (Reload) button, you would have the very first page.
If you need the Back and Forward buttons, then you should create you own. You can create them at the top-left corner inside your web page. You have to write code for them, so that when each one is clicked, the necessary page will be displayed (from the array). With the simple example we had, the pages are in string forms in the array in the master page. The functions for the buttons would be easy to write if the contents of the pages do not depend on one another.
Rendering Web pages as they arrive
With the Ajax approach to ACP, the first web page should be rendered as it arrives at the browser. If you design your web page according to normal CSS flow, it should be rendered by the browser as it arrives, everything being equal.
The main problem occurs with HTML tables. If you want a table to be rendered as it arrives, declare column properties (e.g. widths) at the start of the table definition. Avoid the particular use of "0*" to specify column width. If you do not specify the column widths, the table may not be rendered incrementally, as it arrives.
The secret lies in giving the table column widths values at the beginning of the table definition. The widths can be in pixels, percentage or proportionally e.g. width="3*".
Advantages of ACP
Before we end this part, let us recall the advantages of ACP.
Any information stored at the server and its analysis can be presented quickly to the user with ACP, independent of whether the Internet connection is fast or slow. Only the first page may take some time to download through a slow Internet connection.
Web pages are becoming voluminous because authors are putting a lot of script into them. This leads to lengthy download times. With ACP, downloads won't take so long.
If you understand your scripting language very well, you will pay less for hosting since the analysis will now be done by your script at the client and not by some program at the server.
ACP frees the server from work and so increases overall speed of the World Wide Web. If every client uses ACP, a client will not have to wait too long for the server to serve other clients before it is served, since the processing will be done at the client and not at the server. In other words, the server will spend less time serving a client. One of the aims of N-Tier systems is to free the server from work. ACP also serves that purpose.
We will stop here and continue in the next part of the series.