I am using hook_menu to setup a link which I'm calling via JQUERY from an AJAX application. My hook implementation is as follows:
function staff_filter_menu(){
$items = array();
$items['staff/filtering/results/%'] = array(
'page callback' => 'staff_filter_function',
'page arguments' => array(3),
'access callback' => TRUE,
'type' => MENU_CALLBACK,
'delivery callback' => 'staff_filter_deliver',
);
return $items;
}
This link is the point of contact for my ajax app which is a simple textfield where users type in some input. *staff_filter_function* searches the database and returns some matching data. Ajax code is as follows:
$.ajax({
url: Drupal.settings.CALL_BACK + '/' + $(this).val(),
success: function($data){
.... more stuff done here
}
});
It all works perfectly well but for one small detail. I want to allow a shortcut which will allow all results to display. This shortcut is simply typing a single space. But, because hook_menu is expecting an argument at the end of the url, my ajax request fails whenever I type in a space. It works perfectly when I type in real content.
This is just for completeness and it a nice to have feature ... if anyone can share some ideas, I'll be very great greatful.