Book Image

MooTools 1.2 Beginner's Guide

Book Image

MooTools 1.2 Beginner's Guide

Overview of this book

MooTools is a simple-to-use JavaScript library, ideal for people with basic JavaScript skills who want to elevate their web applications to a superior level. If you're a newcomer to MooTools looking to build dynamic, rich, and user-interactive web site applications this beginner's guide with its easy-to-follow step-by-step instructions is all you need to rapidly get to grips with MooTools.
Table of Contents (14 chapters)
MooTools 1.2 Beginner's Guide
Credits
About the Authors
About the Reviewer
Preface

Time for action—updating a web page with HTML


We'll use the Request.HTML to update a web page with HTML data. This can be useful when you are receiving data as HTML markup.

  1. First, we create a text file that holds our HTML data. Save this text file in the same location as the HTML document that will contain your MooTools code. For the text file, I used the following markup (and again, feel free to customize your HTML document):

    <html>
    <head>
    </head>
    <body>
    <ul>
    <li>List item #1</li>
    <li>List item #2</li>
    <li>List item #3</li>
    </ul>
    </body>
    </html>
    
  2. Create a new HTML document that will serve as our web page; it will contain our MooTools code and the following HTML markup:

    <body>
    <a href="#">Click to make the request!</a>
    <div id="holder"></div>
    </body>
    
  3. Create an event handler for the<a> element being clicked (which triggers the request).

    <script type="text/javascript...