Using requestAction & custom layouts to add XHR functionality
4 : Live example and full code
This tutorial outlines a method for creating or modifying Cake apps that work swiftly for XHR(XmlHTTPRequest)-enabled clients and degrade well to non-XHR/AJAX (even javascript disabled) clients. The guidance provided here will be most suitable to newly converted Bakers. It simply outlines some of Cake's many flexible features and shows how using them in combination can bring rapid returns.
Live Example and full code
A live example and archive of the MVC classes, views and layouts can be found here:http://ajax1app.codeandeffect.co.uk/calendar
A full code listing also follows on the next page, but take care to note which views are views, and which are layouts
Conclusion
This method allows you to develop an application without Ajax or XHR but add it easily with only a little forward planning.
You can concentrate on building a solid Cake App regardless of additional user friendly add-ons, safe in the knowledge that Javascript is not required. Then just add the necessary additional layouts to javascript within them to rollout user friendly features. Your code remains very clean.
Links
requestAction API reference:
Mootools: http://mootools.net CakePHP API, reuqestAction: http://api.cakephp.org/class_object.html#c40a38b60a3748b9cf75215b92ee3db1
Latest Comments