Created
June 4, 2015 06:45
-
-
Save light9/ac01cd359e9cf23828f9 to your computer and use it in GitHub Desktop.
send variable from .php file to .js file in Drupal 7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| drupal_add_js(array('YOURMODULE' => array('testvar' => $testvar)), array('type' => 'setting')); | |
| And in your JavaScript, you can the access the value in Drupal.settings.YOURMODULE.testvar: | |
| alert(Drupal.settings.YOURMODULE.testvar); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment