>All Tutorials 
Ajax and .NET Ajax and .NET RSS XML
Ajax and ColdFusion Ajax and ColdFusion RSS XML
Ajax and Java Ajax and Java RSS XML
Ajax and PHP Ajax and PHP RSS XML
Ajax and SOA Ajax and SOA RSS XML
Ajax Goodies Ajax Goodies RSS XML
Ajax Tool Ajax Tool RSS XML
Facebook MockAjax Facebook MockAjax RSS XML
Google Web Toolkit Google Web Toolkit RSS XML
JavaScript Framework JavaScript Framework RSS XML
Ruby on Rails Ruby on Rails RSS XML
Technique Introduction Technique Introduction RSS XML
Without XMLHttpRequest Without XMLHttpRequest RSS XML
Yahoo! UI Yahoo! UI RSS XML

Processing Forms with xajax - form xajax function array parameter php id note

 
Registered tutorials: 501
Registered Users: 24390



Rating: 4 out of 10 votes cast


  
Category: Ajax and PHP

Processing Forms with xajax

Digg this   Post to del.icio.us

Abstract: The tutorial Illustrates how to process form with Xajax. Also, it introduces the new feature - partual form submition

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 (
    => 'check1',
    => 'check2',
    => 'check3',
  ),
)

Read Full Tutorial...



Reviews:

Rate and Review This Site

No reviews yet


Statistic Information About this Resource:


Total Hits: 2457
Unique Hits: 2102


  Daily Weekly Monthly
  Unique Total Unique Total Unique Total
Average 1.7 1.9 12.9 14.8 65.8 76.3
Current 2 3 11 13 51 60
Previous 5 6 14 15 78 88
Jul 22 2 2 13 15 0 0
Jul 21 2 2 18 22 78 88
Jul 20 1 1 22 26 115 139
Jul 19 1 1 1 1 124 149
Jul 18 0 0 20 22 0 0
Jul 17 1 1 18 20 53 59
Jul 16 2 2 12 14 86 97
Jul 15 1 1 0 0 73 83
Highest 19 23 83 99 304 353


Script Execution Time: 1.4104 | SQL Queries: 10 | Members: 501
Ajax Tutorial Top List - Powered by Aardvark Topsites PHP 5.1.2