This class allows the client script executing the code on the server side using the includes.
To use SimpleAjax class, please complete the following steps:
Create a SimpleAjax instance, for this you have to call SimpleAjax constructor. The script that involves the class containing the necessary methods should be the argument for the constructor;
Call the addParam method with sysparm_name parameter and method name from include part of the script you want to call.
(Optional) Call the addParam method more than once to provide other parameters to the script code. Run the code on the server side calling getXML().
addParam(param, value)
This method specifies the parameter name and its value to be passed to the server-side function, associated with current SimpleAjax object. You can run the addParam() method more than once with different parameters and values.
The server-side code does not execute until client script will not call getXML(). Parameter name should start with sysparm_ prefix. Avoid using a predefined sysparm_name parameter name for
Parameter(s):
Name
Type
Mandatory
Default value
param
String
Y
N
value
String
Y
N
Return:
Type
Description
Void
This method does not return a value
Example:
addParam
const calculate = new SimpleAjax('DurationCalculator'); // call script include
calculate.addParam('sysparm_name', 'getDuration'); // call class method
calculate.addParam('sysparm_start', s_form.getValue('start')); // pass parameter
getXML(callback)
This method sends the request to the server to execute a method and parameters related to current SimpleAjax object. The server processes the request asynchronously. The results will be returned via the function specified as a callback.
Return:
Type
Description
Void
This method does not return a value.
Example:
getXML
const calculate = new SimpleAjax('DurationCalculator'); // call script include
calculate.addParam('sysparm_name', 'getDuration'); // call class method
calculate.addParam('sysparm_start', s_form.getValue('start')); // pass parameter
calculate.addParam('sysparm_end', s_form.getValue('end'));
calculate.addParam('sysparm_schedule', s_form.getValue('schedule_id'));
calculate.getXML(callback);
runScript(scriptValue, tableName)
This method allows to run a script against a table specified.