Index

Classes

Namespace

Variables

Functions

xpAjax

Author: Ricardo Luiz Rossi at sites.google.com/site/rlrossi
rlrossi@gmail.com
Version 1.00.000

Constructor Detail
xpAjax

xpAjax - eXPress AJAX Javascript Class
Deals with the various details of AJAX calling (such as create the proper XMLHttpRequest for the browser/version in use) and process the results, making very simple to implement AJAX requests and result evaluation.

Parameters:
{String} repository
The root URL where to find the servers' scripts for the current instance of the ajax object
Returns:
void
Field Detail
{Constant:Value = 2} _fieldvalue

A single AJAX server parameter should be loaded from an indicated fieldid

{Constant:Value = 1} _formvalues

AJAX Server parameters should be loaded from the fields of an indicated formid

{Constant:Value = 0} _uservalues

AJAX Server parameters will be supplied by the user

<inner>
{String:copy of the constructor's repository parameter} serverRepository

The root URL where to find the scripts to be called by the current instance of the ajax object

Method Detail
<private> <inner>
{String} addProperty(id, value)

Add a property to json's ajax query String

Parameters:
{String} id
The id of the property
{String} value
The value of the property
Returns:
{String} Formatted JSON String of the property as of "id":value
<private> <inner>
{String} createParmsFromField(fieldid)

Creates a JSON like parameter to be used in the AJAX call from a supplied form field ID using addProperty Method

Parameters:
{String} fieldid
The id of the form field We wish to use as AJAX parameter
Returns:
{String} addProperty's formatted JSON String
<private> <inner>
{String} createParmsFromForm(formid)

Creates a JSON like parameter to be used in the AJAX call by iterating all elements of a supplied form ID using addProperty Method

Parameters:
{String} formid
The id of the form We wish all it's elements in the AJAX parameter
Returns:
{String} addProperty's formatted JSON String
<private> <inner>
{String} createrequest(script, parameters)

Creates the AJAX complete request URL to be used in an AJAX.GET calls with the script to be called and it's parameters

Parameters:
{String} script
The script name that could be found in the serverRepository property
{string} parameters
The parameters to be sent in the script's URL
Returns:
{String} The complete and formatted AJAX request URL so We can use it in an AJAX.GET call
<private> <inner>
{Mixed} evaluate(evalString)

Evaluates a String into a Javascript code

Parameters:
{String} evalString
The String containning the javascript code to be evaluated
Returns:
{Mixed} The result of the evaluated Javascript-code-String OR, if an error occurs, a JSON object describing this error with the following properties:
{"error":8,"msg":"The error message","src":"The supplied evalString"}
<private> <inner>
{String} replaceAll(source, search, replacement)

replaces all ocurrences of an String pattern with another one

Parameters:
{String} source
The source String where to search for a pattern
{String} search
The pattern to be searched for
{String} replacement
The replacement String to be used as substitution when search pattern is found
Returns:
{String} The source string replaced
{void} send(Script, callBack, Parameters)

Executes an AJAX request URL to be used in an AJAX.GET calls with the script to be called and it's parameters

Parameters:
{String} Script
The script name of the AJAX processor that should be called, which can be found in the 'serverRepository' property
{String} callBack
The function name that will be called to deal with the results when AJAX processing is done.
Optionaly the word 'discard' can be used as a callback function name, when We dont't need to process the results and all We have to do is to discard the results of the AJAX call.
{string} Parameters
A JSON string with the parameters to AJAX processos in the format:
    {"sourceparms":"Type","p1":value,..."pn":value)
Being 'Type' one of the constants '_formvalues', '_fieldvalue' or '_uservalues' described above.

For '_uservalues' Type, the class expects a list of users's parameters.
Ex.: {"sourceparms":+xpAjax._uservalues+,"p1":1,"p2":"2"}

For '_fieldvalue' Type, the class expects a JSON property called 'objectid' indicating the FIELD-ID in the current document to find the parameter.
Ex.: {"sourceparms":+xpAjax._fieldvalue+,"objectid":"phone"}

For '_formvalues' Type, the class expects a JSON property called 'objectid'
indicating the FORM-ID in the current document to find the parameters.
Ex.: {"sourceparms":+xpAjax._formvalues+,"objectid":"books"}
Returns:
{void} The callBack function will be called to deal with the results OR, if an error occurs, a JSON object describing the error with the following properties:
{"error":9,"msg":"The error message","src":"The result of the AJAX call"}
<private> <inner>
{Object} xmlhttprequest()

Instantiate a proper XMLHttpRequest by trying the most known browsers XMLHttpRequest libraries

Throws:
{XMLHttpRequestError}
A message indicating that We were unable to find a proper XMLHttpRequest library for this session
Returns:
{Object} The object linked to the XMLHttpRequest instantiated

Documentation generated by JsDoc Toolkit 2.4.0 on Fri Feb 22 2013 22:54:24 GMT-0300 (BRT)