xajax.getFormValues()
xajax makes processing form data asynchronously extremely easy. The xajax.getFormValues() method can be used to automatically extract the data from a form and pass it as a parameter to a PHP function you have registered with xajax.
xajax.getFormValues() takes one mandatory argument, which can be either the id of the form you want to process, or the actual form object (see Note below). You use xajax.getFormValues as a parameter to your xajax function, like this:
xajax_processFormData(xajax.getFormValues('formId'));
where xajax_processFormData() is your function that takes the form data as a parameter.
xajax generates a query string representing the form data which is parsed by the xajax server and passed to your PHP function as an array representing the form data, just as if you had submitted the form and used the PHP $_GET array.
NOTE: Your PHP function definition must have a parameter for the array, otherwise the form variables will not be passed to the PHP function.
NOTE: Do not try to access $_GET... Your handling PHP function should look like MyFunc($dta).
When it gets invoked the array of form variables will be passed in $dta and you can handle it like any other associative array. I tried $_GET to no avail. (Note to the note: you could get the data from $_POST['xajaxargs'][0] where it's encoded as an XML xjxquery tag -- but why not just let xajax make your life easier here? Besides, it could change in future versions.)
xajax will even handle complex input names to generate multidimensional and associative arrays. For instance, if you have a form with three checkboxes and you give them all the name "checkbox[]", but different values like "check1", "check2", and "check3", and you use the xajax.getFormValues function as a parameter to your xajax function, the PHP function will receive an array that looks like this:
array (
'checkbox' =>
array (
0 => 'check1',
1 => 'check2',
2 => 'check3',
),
)