xajaxでのフォームの扱い方

間隔があきましたが、引き続き。
ググると出てきますが、なかなかたどり着かないのと、なくなるとショッキングなので、
こちらに記載。(将来的にはWikiとかで参照しやすくしたいな。。。)

http://www.xajaxproject.org/docs/processing-forms-with-xajax.php

で和訳はこちら。
http://dev.xajaxproject.org/wiki/JP:%C3%A5%E2%80%A6%C2%A5%C3%A9%E2%80%93%E2%82%AC:Forms%C3%A5%E2%80%A1%C2%A6%C3%A7%C2%90%E2%80%A0

xajax.getFormValues()

ajax 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では、非同期formデータ通信処理がとても簡単です。xajax.getFormValues()メソッドが自動的にあるformからデータを抽出して、xajaxオブジェクトに登録したPHP関数に渡されます。


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.getFormValues()が少なくともひとつの引数が要求されます。この引数はformのID名もしくはformオブジェクトです。(下記のNoteを参考してください)。たとえば下記のようにxajax.getFormValuesをxajax関数の引数として使用することができます:

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.
一般的なformデータとPHPの$_GET配列の扱い方法に似てるが、xajaxがxajaxサーバ経由でformデータからクエリ文字列を作成し、PHP関数に配列として渡されます。


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: あなたのPHP関数には必ずこの配列を関数引数そして定義する必要があります。そうでなければformデータが正しくPHP関数に渡されません。


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.)
NOTE: $_GETが使えません... あなたのPHP関数がMyFunc($dta)のようにしないといけません。formデータ配列がこの$dta変数に渡されるのであとは通常な配列扱いのみです。$_GETが無用です。


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:
xajaxは、複数な入力を取り扱うため多次元の連想的な配列を使います。たとえば、formに要素名"checkbox
"の3つのチェックボックスがあって、それぞれのバリューが"check1", "check2", "check3"とします。xajax.getFormValuesをxajax関数の引数として使用することで下記のような配列を取得することができます:

array (
  'checkbox' => 
  array (
    0 => 'check1',
    1 => 'check2',
    2 => 'check3',
  ),
)


The array argument to your function mirrors the structure that the $_GET array would have if you were to submit the form traditionally. You can then access the checkbox data in the array like this:
これで要素名の'checkbox'入力データを下記のように扱うことができます: $aFormData['checkbox'][0]

$aFormData['checkbox'][0]


NOTE: Make sure that you assign your forms an id in addition to a name attribute. If you have failed to assign an id to the form, Internet Explorer uses the value of the name tag for the id and the getFormValues function will appear to work anyway. Firefox, on the other hand, can't find the form unless you explicitly set the form id.
NOTE: form id が必ず指定しなければなりません。idがない場合、Internet Explorerがnameタグを利用することが可能なので動作できますが、Firefoxが正しくformを見つけることができません。


NOTE: When using Firefox, make sure to assign a name attribute to all input types that you want the getFormValues function to grab. Just an id attribute will not work.
NOTE: Firefoxの場合、すべての入力要素にname属性を指定すべきであります。id属性のみの場合は正しく動作しない可能性があります

Submitting just a part of the form

formの一部データのみを扱う場合


If you want only a part of the form elements to be submitted (a subset of the form), there is a new option starting with 0.2.1. There is an optional parameter to xajax.getFormValues, specifying a prefix -- if set, only form elements starting with that prefix would be submitted to the PHP function. This can be very handy when you have a large form and only want to update a subsection of it. The prefix parameter is the third parameter of the function, the first being the form's id and the second being a boolean indicating whether to submit disabled fields.
バージョン0.2.1からformの一部データのみを扱うために新しいオプションが導入されました。xajax.getFormValuesの引数にオプションのパラメータがあります。接頭辞を指定して、その接頭辞から始めているform要素だけはPHP関数に渡されます。大きなformに一部データしか処理しない場合はこの方法がとても便利です。接頭辞パラメータは、関数の第3のパラメータです。formIDが第一パラメータで、そして第2パラメータがdisableされた項目データを処理するかどうかのboolean型値となります。


So the full syntax becomes:
xajax.getFormValuesの構文が下記となります:

xajax_processFormData(xajax.getFormValues(formID[,bSubmitDisabled[, prefix]]));

そのほか、getValue系の情報。
http://blog.livedoor.jp/loopus/archives/50181959.html

http://programming-magic.com/?id=138