Making an Ajax call

Getting ready

Asynchronous JavaScript and XML (Ajax) saves time by updating a page without refreshing it completely. Ajax has been around for a long time, with varied limits of browser support. It is safe to say that Google is most guilty of showing the world how easy it is to use.

How to do it...

Now with the MooTools abstraction layer's Request object, Ajax is child's play.

<script type="text/javascript" src="mootools-1.3.0.js"></script> </head> <body> <form action="" method="get"> <input type="button" id="mybutton" value="Ajax!" onclick="ajax_it();"/> </form> <script type="text/javascript"> var myJax = new Request({ url: '?', onSuccess: function(response) { alert('Success! Here is the response: ' +response); } }); function ...

Get MooTools 1.3 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.