July 2011
Intermediate to advanced
276 pages
5h 11m
English
The creation of new DOM elements with MooTools is elementary, as is calling asynchronous JavaScript requests, Ajax. Here we combine the two for a very reusable recipe where the results of a form submission are displayed on the same page as the request. Hook the Ajax call up to your server-side script and make form magic. To avoid the necessity of server-side scripting, we call our own HTML markup and display that in this example.
<form action="javascript:" method="get"> <input type="button" id="mybutton" value="Ajax and Response!" onclick="ajax_it();"/> </form> <span id="put_it_here">Waiting for form submission...</span> <script type="text/javascript"> // A // make a new ajax request ...