Dark Light

One of the problems with Ajax is that the server side of it becomes invisible. You send a request to the server with an ajax request object, and you can get output from the JS by firebug, or alert boxes, or whatever, but for the script running on the other side, there’s no visible place for the output.

There are many ways around it, but my current favourite is Growl.

Growl is a notification system for OS X, where programs send messages to the central demon, and it pops up a little dialog message that eventually fades away. They’re nice for debug, so I have this:

require_once 'Net/Growl.php';

$growl =& Net_Growl::singleton('Net_Growl'array('Messages'), '[Password]');
$growl->_options['host'] = '[MyIP]';

$GLOBALS['growl'] = $growl;

function debug($message){
    $backtrace = debug_backtrace();
    if (is_array($message) || is_object($message)){
        $message = print_r($message,1);
    $title = sprintf("Debug - %s - %d"$backtrace[0]['function'], $backtrace[0]['line']);


With network notification enabled on Growl on my local machine, I get a little debug message without interrupting the application flow.

Of course, I could use log files, but that wouldn’t be quite as pretty.

Related Posts