Eight Weeks of Prototype: Week 5, Ajax with Prototype
Summary
In this article I showed you how to perform Ajax requests using the Ajax.Request provided by Prototype. This class is a wrapper to the XMLHttpRequest object that modern browsers have. I showed you how to specify options when performing a request, including how to specify the callback handlers to deal with the response from the HTTP sub-request.
Additionally, I introduced you to JSON data and how to send JSON data with PHP, and receive it in the Ajax response. While the examples given were mostly conceptual, hopefully they gave you a good idea of how you can use Ajax in your own applications. In the eighth article of this series a larger, more concrete example will be given when I bring together all of the Prototype functionality covered in this series.
In the next article I will show you how to create JavaScript classes in Prototype. If you prefer an object-oriented approach to your programming, you will find this article invaluable, since knowing how to effectively create classes will give your code a much better overall structure.
Other Options
- Download a PDF version of this article
- Put your PHP knowledge to the test with our online and iPad/iPhone quizzes
- View or post comments for this article
- Browse similar articles by tag: Ajax, JavaScript, JSON, PHP, Prototype
-
Read related articles:
- Eight Weeks of Prototype: Week 1, Beginning with Prototype
- Eight Weeks of Prototype: Week 2, How Prototype Extends Elements
- Eight Weeks of Prototype: Week 3, Prototype Data Types
- Eight Weeks of Prototype: Week 4, Event Handling in Prototype
- Eight Weeks of Prototype: Week 6, Writing JavaScript Classes with Prototype
- Eight Weeks of Prototype: Week 7, Other Prototype Functionality
- Eight Weeks of Prototype: Week 8, A Complete Prototype Example




