xpAjax
Author:
Ricardo Luiz Rossi at sites.google.com/site/rlrossi
rlrossi@gmail.com
Version 1.00.000
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
A single AJAX server parameter should be loaded from an indicated fieldid
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
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
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
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
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"}
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
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"}
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