Urania Virtuelt Observatorium portal Det Kongelige Bibliotek

The "Ajax model"

Ajax stands for Asynchronous JavaScript and XML. It is the technique we have used for some of the web pages on this site to get information (entered by the user) from a form on a web page to a script, and to get output (e.g. a plot) from the script back on the web page for the user to see.

In the "Ajax model" in our implementation, there are 3 principal components/files involved (the example file names are from http://www.astro.ku.dk/urania-vo/modules/pickles_1998/):

  1. HTML code
    (example file: /local/www/home/urania-vo/modules/pickles_1998/index.html)

  2. JavaScript code
    (example file: /local/www/home/urania-vo/modules/pickles_1998/index.js)

  3. Backend script
    (example file: /local/www/cgi-bin/urania-vo/pickles_1998.pl)
The advantage of this way of doing things is that the script in some sense can update the original web page by replacing the div tags with new content, e.g. a plot generated by the script. This seems to be achieved using something called DOM scripting, in which the script writes directly into the DOM tree (which means that a "View source" in the web browser won't show the new content but rather just the seemingly empty div tags, but if the DOM tree is browsed, the new content is seen). The disadvantage is that the JavaScript code has to be made.

One alternative to the Ajax model (and how the old Urania AVO site does things) is just to have an HTML file and a script file. In this model, the script file has to generate and entire new HTML page, which is mostly identical to the old page except the new content now has been coded in. This setup means that changes to the page has to be made in two places: in the HTML page the user meets to begin with, and in the code of the script which generates the HTML page the user gets after having submitted info via the form.

Note that we are not taking advantage of the possibility of asynchronisity in Ajax, i.e. the feature of communicating back and forth with the backend script as the user types e.g. each letter of an input sentence (using something like <input type="text" name="txtfoo" ID="txtfoo" onkeyup="findPartialfoo(this.value)">, cf. this document).

Back to the main page of the site


Bo Milvang-Jensen 2008-2009. Page last updated: 28-May-2009