Developing Web Applications with Ajax, Part 4
Developing Web Applications with Ajax, Pt. 4
This form submits to the following PHP file, ajax_output.php, which takes the data and outputs it.
The output is a DIV that contains a couple of paragraphs. If the name field is filled in, it will output "Hello, [your name]." If the hair field is filled in, it will say "You have [hair color] hair!" If you put in both, it will output both messages in the same DIV.
This script is very versatile and is useful in many situations, since you can put any form elements within the form above and the data will be POSTed to the form's action without reloading the page. You need simply modify the form's action file to reflect changes of input names in the form and how to handle that data.
About the Author
Created: November 15, 2005
Revised July 19, 2006