Javascript Execution of Rule Sets |
Top Previous Next |
A function is supplied in the ufarc.js Javascript library that is loaded into web forms. This function executes a rule set on the server, and the rule set's cgiresponse$ value is returned to Javascript.
The syntax of this function is:
var txt=runRuleSet("rulefile","ruleset",flds[,args[,callback]])
The rulefile and ruleset arguments are self-explanatory, as they simply become –f and –r arguments to an UnForm job. The flds argument can be either a URL=encoded string, such as "name=Jim%20Smith", or an JavaScript object containing name:value pairs, in which case the function will URL-encode all the names and values. The fields defined in this argument are available in the rule set as cgi.name$.
If additional job command line arguments are required, they can be supplied in the optional args string argument.
If a callback function is supplied, it is executed when the request completes, and is supplied with the request response as its only argument. If no callback function is supplied, the request runs synchronously, and will return the server's response to the function. Note that running the function synchronously is not always supported by modern browsers. The preferred method of executing this function is with a callback function rather than expecting a text response.
Note if there is data in delimited or INI format available on the server and needed in Javascript, there is a json object that can be used in the rule set to convert such data into JSON format, enabling easier and faster access in the script code.
|