You can check module is enabled or not using module_exists function... Ideally your .module which checks for above condition and sets variable for JavaScript
file goes below..
See detailed steps below on adding this condition
- Create a folder called 'custom' in
sites/all/modules
- Create a folder called 'mycustomjs' in above custom folder
- Create a file called 'mycustomjs.info' inside above folder with
below code
name = My Custom JS Alters
description = A custom module to interact with JS
core = 7.x
package = Custom
Create a file called mycustomjs.module inside 'mycustomjs' folder with
below code
<?php
function mycustomjs_preprocess_page(&$vars) {
$module = "MODULENAME"; // Change modulename to module you want to verify
$does_module_enabled = module_exists($module);
if ($does_module_enabled) {
drupal_add_js(array('MODULENAME' => array('enabled' => TRUE)), 'setting');
}
else {
drupal_add_js(array('MODULENAME' => array('enabled' => FALSE)), 'setting');
}
}
?>
For more information See the Creating Drupal 7.x modules if you're not sure
Can you just not add the AJAX part in your module if the require module isn't enabled -
I dont think we can make ajax call in module, ajax call is made only in JS , AM i right? ... what are you trying to say