Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By esperveras on
I need creating module that working with javascript, how can i get back the variable i passed from module file to js file ? I want to use it in module file but i cannot get it's value.
Comments
Not sure if I undsrstand but
Ok it seems you want to pass some javascript to some php. To do this, you can use javascript/ajax to send the information through a url / xmlhttp and then use php $_GET['var'] to grab the information. That is the only way I know of to pass javascript to php. Using cookies pro would work too. Use javascript to set the cookies and have PHP get it.
Yes, that's the way i'm
Yes, that's the way i'm thinking for, but it's not working. I use POST method instead of GET method
this is my code in js file
And this is my menu callback:
i don't know how it's not working :(
i attached it with click function but nothing happened when i clicked a button.
At a glance, it looks ok. A
At a glance, it looks ok. A couple of questions:
1) Have you looked in either firebug on firefox, or the developer tools in Chrome or Safari to see if the request is actually being fired?
2) On that same note, are any javascript errors being seen in the consoles on either of those?
Also, what does your .click() function look like?