O'Reilly logo

MooTools 1.3 Cookbook by Jay Larry G. Johnston

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating a DIV displaying an Ajax form response

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.

How to do it...

<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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required