This project is read-only.

Javascript server calls

XsltDb allows you to setup a module that really doesn't display any html code but mapped to a javascript function, that returns result of XSLT transformation as a string. To do that just include the following preprocessor directive:

##handler:fun_name ( [ parameter1 [ ,...n ] ] );

Values of parameters passed to the javascript function are POSTed to the server and available through mdo:request extension. The following example shows current server date and time. First, setup js server-side handler. To do that create an XsltDb module:

{{mdo:fmtdate(mdo:date(), mdo:request('format'))}}
Then create HTML block (you can also use XsltDb or standard Text/HTML module)

<input type="button" value="Show Time" onclick="alert(getServerDate('hh:mm:ss dd.MM.yyyy'))" />
Or (asyncronously)

<script type="text/javascript">
  function showDateTime()
    getServerDate('hh:mm:ss dd.MM.yyyy', function(text){
<input type="button" value="Show Time" onclick="showDateTime()" />
Now click "Show server date and time" link and you will seea message box with server time and date.

See also XsltDb javascript API for another way of AJAX-ing.

Last edited Jun 18, 2010 at 5:44 PM by findy, version 6


No comments yet.