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—getting the Last-Modified HTTP header


We are going to get HTTP headers from the server during our Ajax request. This can be helpful in displaying contextual information about the server that's sending us our response. In this particular instance, we're going to determine when the file that we requested was last modified.

  1. The first thing we're going to do is get the time when our HTML document was last modified. Start by creating an HTML document and saving it onto your server with MooTools ready to go.

  2. Next, set up our MooTools Request object. For the url value, set it to the name of the HTML document that you uploaded to your server. We will use the onSuccess Request class method to watch for the eventuality that our Ajax request was successful. Upon success, we alert the date that the HTML document was last modified by getting the value of the Last-Modified HTTP header using the getHeader method. Finally, we use the send() method to initiate the Ajax request.

    <script type...