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.
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.
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 theonSuccess
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 theLast-Modified
HTTP header using thegetHeader
method. Finally, we use thesend()
method to initiate the Ajax request.<script type...