Drupal 7 skip loading the template for ajax requests
How are you generating the ajax response?

If you simply want to return a string eg a file name you can just return it as plain text or as JSON using hook_menu and a callback function eg:

function mymodule_menu() {
    $items['my/custom/path'] = array(
      'page callback' =&gt; 'mymodule_callback',
    );
    return $items;
}
function mymodule_callback() {
  //Do stuff like get filename from DB.
  print 'filename.jpg';

  //to return JSON use drupal_json
  //drupal_json(array('filename' =&gt; 'filename.jpg'))
}