I am building a complex AJAX based solution as a module into a Drupal 7 site. I decided not to write a standalone PHP script to respond to my jQUERY ajax call but implement the code within my drupal module.
My problem is establishing the connection between jQUERY and DRUPAL i:e the function which responds to my CLICK EVENT.
I was using the following code:
function staff_filter_menu(){
$items = array();
$items['staff/filtering/results/%'] = array(
'page callback' => 'staff_filter_function',
'access callback' => TRUE,
'type' => MENU_CALLBACK,
'delivery callback' => 'staff_filter_deliver',
);
$items['staff/filtering/saveclipboard'] = array(
'page callback' => 'staff_filter_savetoDB',
'access callback' => TRUE,
'type' => MENU_CALLBACK,
'delivery callback' => 'staff_filter_deliver',
);
drupal_flush_all_caches();
return $items;
}
But, it stopped working when I stopped, uninstalled and restarted the module. It seems to not be a reliable strategy.
drupal_flush_all_caches()does this:When the menu is rebuilt,
hook_menu()is called…basically you’re causing an infinite loop by puttingdrupal_flush_all_caches()where you currently have it.