Data Access

For small-scale data access applications, JavaScript can be used as a quick and simple alternative to CGI. Rather than make a request to the server each time, data (complete with pictures) can be embedded into the body of an HTML document, and accessed via a scripted form, removing the need to communicate with the server and vastly speeding up the process.

To illustrate this, the following example shows the product database of a fictitious leisure enterprise, Rollin' Joe's Marble Emporium. You can use the form to browse through Joe's range of fine marbles.

Rollin' Joe's Marble Picker

Marble Pick a marble:

Because the data is embedded into the HTML document, this technique is only effective when there is a relatively small amount of information to transfer, or the increase in speed due to the client-side processing will be outweighed by the time it takes to download the page. Large databases are best kept on the web server, using a CGI script to access them. It will also be much easier to maintain and update a large database in this way.