Drupal.settings.mymodule is not an object
It should be:

drupal_add_js(array('mymodule' =&gt; $vars), 'setting');


But ideally you'd be using a render array instead, and loading the settings/files into the page with the #attached method.