I have developed a custom module and I am facing an issue where I need to pass the fetched database value $flag=1 to a JavaScript file in Drupal 7. However, when I try to access the variable 'aniv' in the JavaScript file, it shows as 'undefined'.
module file
$flag=1; //assume fetched from database
drupal_add_js(array('one_time_popup' => array('aniv' => $flag)), array('type' => 'setting'));
drupal_add_js(drupal_get_path('module', 'one_time_popup') . '/service.js','file');
$settings=variable_get('one_time_popup_effects',(ONE_TIME_POPUP_DEFAULT));
drupal_add_js(array('onetimepopupmenu'=>$settings),'settings');
service.js
console.log(Drupal.settings.one_time_popup.aniv);