Big Sister Web Application Framework
Functions
SwafAsync.js File Reference

Functions

function SwafAsync ()
 Implements asynchronous server requests (aka XMLHttpRequest).

Function Documentation

function SwafAsync ( )

Implements asynchronous server requests (aka XMLHttpRequest).

SYNOPSIS

var req = new SwafAsync();
req.setHandler( function(req) {
// insert the results into the existing <div id="results">...
if( req.isStatusOk() )
req.insertBody( req.clearNode( document.getElementsById('results') ) );
} );
req.postForm();
create an XMLHttpRequest object - browser dependent.

XMLHttpRequest

post current form values. Posts a form document asynchronously in the background.

Template Parameters
Stringuri (optional) the URI of the server-side script. If no URI is given, the action of first form in the document is used.
Arraynames (optional) the names of the form elements to be posted. If no names list is given, then all the elements are posted.

post arbitrary data. Posts arbitrary name/value pairs to a server-side script.

Template Parameters
Stringuri The URI of the server-side script.
Arraynames A list of argument names.
Arrayvalues A list of argument values.

Interprets response text as a JSON object.

Template Parameters
Stringtext (optional). JSON text - if none is given takes the response of the current request JSON the text translated into a JSON object

Sets the handler that is to be called when the request is complete. The handler function is called with one argument - the corresponding SwafAsync object.

Template Parameters
functionhandler the handler to be called on request completion

This is called by the browser when the request's state changes.

Inserts an XML response into the current document under a given node.

Template Parameters
nodenode the node under which the document shall be added
Stringelementname (optional) the name of the element in the async request result that contains the nodes to be added. If none is given, "response" is assumed.

Imports an XML tree into the (HTML) document. Called by insertBody() which one should use in preference.

Template Parameters
nodesource the node to copy
nodetarget the node under which the copy shall be stored

Removes all the childs of a node. The node passed is then returned. This is a conveniency function. Use it i.e. like this:

req = new SwafAsync();
...
req.insertBody( req.clearNode( document.getElementById( 'test' ) ) );

node

Template Parameters
nodenode the node to clear

Check the status of a completed request. Status "200" or "0" is treated as ok. boolean true if status is ok

the current request XMLHttpRequest

References contextURI(), and encodeArgument().