-
-
Notifications
You must be signed in to change notification settings - Fork 48
Adding Ajax Functionality
Module authors wishing to add ajax functionality should target Site.ajax_url
in their JavaScripts. The ajax controller offers a trigger-based framework for responding to ajax requests.
You must provide a unique route action in your ajax GET or POST request in order for your request to be routed to a responder in your module. Adding an ajax_foobarbaz()
trigger function to your module will enable your module to respond to requests sent with a POST action of foobarbaz
or sent to /ajax/?action=foobarbaz.
Your trigger function should return an appropriate response object to your JavaScript on either success or failure. If your function returns false
the routing process will continue, and if no other responders are found, it will conclude with a 404 error.
Module authors are encouraged to use the helper function json_response()
when responding to ajax requests. json_response()
encodes a response object containing two properties: text
and data
. Authors are encouraged to always populate the text property with a human-readable response message. The data property can contain any arbitrary JSON-encodable data.
This is the wiki for Chyrp Lite: An ultra-lightweight blogging engine, written in PHP.
- About Permissions
- Tour of a Theme
- Twig Reference
- Twig Variables
- Object Attributes
- Routes and Controllers
- Making Your First Module
- Debug and Tester Modes
- About Errors
- Introduction to Helpers
- Introduction to Translations
- Introduction to Triggers
- Anatomy of info.php Files
- Anatomy of a Feather
- Anatomy of a Module
- Anatomy of a Theme
- Anatomy of a Post
- Localizing Extensions
- Adding Ajax Functionality
- Working with JavaScript
- Working with Model
- Working with Config