This extension provides a set of procedures to use asynchronous callbacks from a browser to a Chicken-powered web-server (for example Spiffy). This is done using Prototype's wrappers around the xmlHttpRequest API.
Specifies how HTML and script-fragments generated by the procedures of this package should be handled. SYMBOL should be either shtml or html, where the former requests output as SXML expressions and the latter as text containing HTML. html is the default.
Holds a procedure that will be called for every registered xmlHttpRequest callback (see below).
Initializes callback handling for this page/response and returns a HTML or SHTML fragment containing a script element linking to the given source filename, which defaults to prototype.js. The Prototype library is included in the distribution and will be installed in the extension repository.
The optional argument KEY is used to make the generated callback-URLs for this page more unique and may be an arbitrary string.
This procedure resets the callback-handling for this response and must be called before using any of the remote-... procedures described below.
Registers a HTTP callback handler for a generated URL that invokes THUNK, a procedure with no arguments. If ARGUMENTS is given, then it should be a string or an association-list mapping URL-encoded argument-names to values. In both cases the arguments will be encoded in the url. If SESSIONID and LIFETIME are given, this url will be expired when the LIFETIME in seconds is passed from the last access of urls with the SESSIONID. If UNIQUEID is given and not #f, it is used to remove the previous url with the same UNIQUEID.
This procedure returns an URL as a string.
The meaning of the various keyword arguments is as follows.
|arguments||A string or an association list of URL-encoded variable/value pairs (see remote-url for more information)|
|update||the id of a document node that should be replaced with the SXML of this reply|
|insert-before||Document-id of element before which the reply will be inserted|
|insert-after||Document-id of element after which the reply will be inserted|
|insert-top||Document-id of element in which the reply will be inserted as the topmost sub-element|
|insert-bottom||Document-id of element in which the reply will be inserted as the bottommost sub-element|
|method||HTTP request method used|
|frequency||The interval in seconds after which the callback should be invoked|
|sessionid||Pass to remote-url|
|uniqueid||Pass to remote-url|
|lifetime||Pass to remote-url|
Returns HTML or SHTML for a link (<a>) that will invoke THUNK when clicked. The KEYWORD-ARGUMENTS are the same as for remote-action.
Returns HTML or SHTML for a button (<button>).
Disables caching of the current page by setting various HTTP response headers. Handy for debugging.
Here we use the ajax extension in an ssp page. To try it out you can invoke csi like this (assuming prototype.js and test.ssp are in the current directory):
$ csi -q #;1> (use spiffy) #;2> (start-server port: 8080 root: "." debug: #t)
<!-- test.ssp --> <html> <head> <?scheme (use ajax) (no-cache) (display (ajax)) (define words '(one two three)) ?> </head> <body> The current time is: <span id="time"><b>...</b></span> <p> <ul id="list"></ul> <p> <? (remote-timer 2 (lambda () (printf "<b>~a</b>" (seconds->string (current-seconds)))) update: "time") ?> <p> <? (remote-button "Click me" (lambda () (printf "<li>~a</li>" (list-ref words (random (length words))))) insert-bottom: "list") ?> </body> </html>
Copyright (c) 2005, Felix Winkelmann. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the Software), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED ASIS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.