AJAX and Mercury
Since this is a document about Mercury and not a general tutorial this section assumes that you already know how to write server-side PHP code to handle server-side AJAX requests. As such there is only really one major thing that you need to keep in mind.
Formatting AJAX Response Documents
When you are sending an AJAX response back to the client keep in mind that the default behavior of Mercury files is to wrap your content in html/layout.php. This is usually not what you want to have happen in an AJAX response. You will probably want to include the following line in your AJAX response files whether they are part of a module in a controller file or if they are standalone files:
<?php
m("core", "setLayout", "");
?>
This will remove the layout file and will send your content back to the browser as-is. While this is mandatory for AJAX you will also use this approach on dynamic CSS and Javascript files.
