Drupal 7 Get field value by machine name and pass to javascript
It should be Drupal.settings.mymodule.test not Drupal.settings.test. All of this code should live in a preprocess hook (either page or node, whichever is more appropriate for your use case). For the node, you can try $node = menu_get_object('node');.

Example:

if ($node = menu_get_object('node')) {
  $tid = $node-&gt;field_test['und'][0]['tid'];
  $term = taxonomy_term_load($tid);
  drupal_add_js(array('mymodule' =&gt; array('test' =&gt; $term-&gt;name)), 'setting');
}


In your console (like Google Chrome) you can type Drupal.settings to see the entire object, and you should see mymodule as a part of it. Within that you will find test with the term name as a value.