On 6/10/05, Eric Lease Morgan <[log in to unmask]> wrote:
> Ajax is a thing I'd like to play with more:
> By exploiting a Javascript function called XMLHttpRequest it is
> possible to create Web pages that seem more like desktop applications.
> By not forcing the user to go from page to page to page it is possible
> to keep the attention of users longer as well as provide a more
> interactive experience. The link above describes this in more detail
> and points to a number of Javascript libraries for a number of
> languages enabling you to write such applications more easily.
> FYI.

<promotion type="shameless">

If anyone feels like digging into an app that's extremely heavy with
XMLHttpRequest stuff you may want to look at Evergreen, a.k.a
Open-ILS.  The entire staff client, which is written in XUL, and the
current version of the OPAC are entirely "ajax" driven.  We use it to
connect, via an Apache module, to our back end cluster.


Another very nice (though not as groundbreaking) technology we've
paired with XMLHttpRequest is JSON.  Yes, it's YAML, but the
speed and ease of use benefits are huge when writing a browser-based

We've extended JSON a bit to handle user defined classes (on the
javascript side) and packages on the perl side.  We hide a "hint" in a
set of comments surrounding the JSON object which tells our code what
class to use so that the JSON string is 100% compatible with any
standard JSON parser, and we don't run the risk of using a property
that someone wants for himself.

   // standard JSON "object" representing a person:
{  'firstname' : 'Mike',
   'lastname' : 'Rylander,
   'age' : 26, 'eyes' : 'blue',
  { 'street1' : '123 main st',
    'city' : 'anywhere',
    'country' : 'usa',
    'zip' : '10101'

  // our extended JSON that will create the correct class
  // instance in any supporting language
/**S person**/ {
   'firstname' : 'Mike',
   'lastname' : 'Rylander,
   'age' : 26,
   'eyes' : 'blue',
  /**S addr**/ {
     'street1' : '123 main st',
     'city' : 'anywhere',
     'country' : 'usa',
     'zip' : '10101'
  } /**E addr**/
} /**E person**/

All of our data is passed around as extended JSON-serialized objects,
so javascript can just use 'XMLHttpRequest.responseText' to get the
content and then 'eval' the objects into existence.  To use our class
hint extensions we simply pass the JSON through a regex to replace the
comments with the appropriate code for instantiating the correct
object, then 'eval' it.

Writing a Perl module to handle our extended JSON was super easy and
we have a C library to handle it as well.  I'm sure any other language
would be very easy to support even with our class hinting extension.

Mike Rylander
[log in to unmask]
GPLS -- PINES Development
Database Developer