Preventing Admin Footer Output in Drupal AJAX Calls
Some administration and debugging modules for Drupal attach their statistics to the end of Drupal rendered pages using PHP's register_shutdown_function function facility. This is great to ensure the output is always available, no matter how badly built the theme being used is.
Examples of modules adding their stats to the footer include the superb Devel package which allows outputting statistics on your database queries (or "Gunk" as its called in the source code), and the Memcache Admin UI module which provides information about the memcache bin usage.
The simple solution is to set a HTTP Header in your custom module before the output. Headers which are recognised by Devel and Memcache vary. Devel recognises
Using the Drupal API add the following before you print your output:
<?phpdrupal_set_header('Content-Type: text/plain; charset=utf-8');
The Devel module also has an extra switch you can set using
<?php$GLOBALS['devel_shutdown'] = FALSE?> to suppress the output, however that doesn't cover the Memcache case.