Get any Drupal data in javascript


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. # In any hook_init().
  2. drupal_add_js(array( 'citris' => array( 'basePath' => base_path(), ), ), 'setting');
  3.  
  4. #In any js inside Drupal
  5. uri = Drupal.settings.citris.basePath + "mypath";

Report this snippet


Comments


You need to login to view comments.