Get Json From Module
Pretty close; here's the correct way:

/**
 * Implements hook_menu().
 */
function YOURMODULE_menu() {
  $items['languages'] = array(
    'page callback' =&gt; 'YOURMODULE_languages_enabled_json',
    'access callback' =&gt; TRUE,
  );
  return $items;
}

/**
 * Render enabled languages in JSON.
 */
function YOURMODULE_languages_enabled_json() {
  $out = array();
  foreach (language_list('enabled') as $languages) {
    foreach ($languages as $language) {
      $out[$language-&gt;language] = $language-&gt;name;
    }
  }
  drupal_json_output($out);
}


The important piece is https://api.drupal.org/api/drupal/includes%21common.inc/function/drupal_json_output/7 which should be used for JavaScript callback functions returning data in JSON format, and it sets the header for the JavaScript output.