Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7540937
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T07:45:52+00:00 2026-05-30T07:45:52+00:00

My issue is passing a PHP variable from my custom module to jQuery. I

  • 0

My issue is passing a PHP variable from my custom module to jQuery. I have successfully done this in the past in D6 but I must be missing something in D7.

The following is my module code:

  function mymodule_init(){
    $path = drupal_get_path('module', 'mymodule');

    drupal_add_js("{$path}/js/filtering.js");
    drupal_add_js(array('staff_filter' => array('path' => $path)), 'setting');

  }

And this is my jQuery code:

(function($){
    console.log( Drupal.settings.toString() );
    console.log( 'TESTING : ' + $(Drupal.settings.path).html() );
    console.log( Drupal.settings.toSource() );
})(jQuery);

And I get the following from my 3 console prints:

[object Object]
TESTING : null
({})
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T07:45:53+00:00Added an answer on May 30, 2026 at 7:45 am

    As you’re adding a setting with a parent called staff_filter your settings will be available under a settings object with the same name in javascript. Your path will be here:

    Drupal.settings.staff_filter.path
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This issue is driving me mad. I have several tables defined, and CRUD stored
Ok this is more of a PHP question than mongodb but since i am
i have a design issue regarding sending user data from a mobile phone app
Edit: If you're coming here from Google, this issue is a result of the
I am having issue passing get variables. index?p=calendar refers to calendar.php located in pages/calendar.php
I have a codeigniter application.In that i call the controller function using ajax/jquery.But when
I have been battling this issue for a few days now and think I
Hi i'm trying to retrieve response after passing some variables from javascript to php
I've consistently had an issue with parsing XML with PHP and not really found
Got a little issue where my client is pasting in content from Word into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.