Advanced examples F.A.Q

CONSTRUCT simplejax(string uri, string callback [, object errorHandler])

Arguments :

Description:

Simplejax library for clean page requests. Supports both POST and GET.

Example:

function fooCallBack(response)
{/* Handle response data */}
function barCallBack(error)
{/* Handle error */}
simplejax = new simplejax('foo.txt', fooCallback, barCallback);

PRIVATE object ^ bool construct()

Description:

Object creation method, privately accessed, handles both ActiveX and Netscape's proprietary object

PUBLIC void set(enum option, mixed value, [,string argument])

Arguments :

Description:

Set options, values are saved in reserved buffer variables and are accessed when invoke method is invoked.

Available options:
string URL - Assign a new url
object CALLBACK - Assign a new callback function
mixed ARGUMENT - Provide the value to an argument in the callback
enum(GET,POST) METHOD - second parameter is the post arguments
bool XML - Return content type as XML
bool JSON - Parse as JSON and return object

Example:

// Changing the set URL
simplejax.set('URL', 'bar.txt');

// Changing the callback
function myCallBack(response)
{
   alert(response.toUpperCase());
}

simplejax.set('CALLBACK', myCallBack);

// Set first parameter (after the response)
simplejax.set('ARGUMENT', 'foo');

// Change the method to post
simplejax.set('METHOD', 'POST', 'foo=bar&bar=bork');

// POST can now accept an array of post values [ new in Simplejax 1.4 ]
simplejax.set('METHOD', 'POST', new Array('foo=bar', 'bar=bork'));

// Set return type to XML
simplejax.set('XML', true);

// Set return type to JSON evaluated object
simplejax.set('JSON', true);

// Set a post parameter on the fly [ new in Simplejax 1.4 ]
simplejax.set('POSTPARAM', 'fieldname', 'value');

PUBLIC void ^bool invoke( [,mixed options])

Arguments :

Description:

Invoke object creation and establish callback.

Example:

<a href="javascript:void(0);" onclick="simplejax.invoke()">Invoke</a>

//Provide the callback arguments with values
simplejax.invoke('foo', 'bar');


PRIVATE void getsource()

Description:

Retrieves source of URI and stores in associated reserved buffer variable and invokes callback function.