Question

I am in the process of developing a module which needs to make an ajax call to a menu path defined by the same module.

Below is the hook_menu function:

function staff_filter_menu(){
        return $items['staff/filtering/results'] = array(
            'page callback' => 'staff_filter_function',
            'type' => MENU_CALLBACK,
        );
    }

    function staff_filter_function(){
        drupal_json( array('status' => 0, 'data' => "staff_filter_function RESPONDING!"));
    }

And the js code:

(function($){

$(document).ready(
function(){
    $results = $.get('http://localhost/test1.localhost/?q=staff/filtering/results');

    //$results = $.get('http://localhost/test1.localhost/?q=admin/config/people');
    //$results = $.get('http://localhost/test1.localhost/admin/config/people');
});

})(jQuery);

The first line (the call to my defined menu) fails and returns a 404 error in firebug.

So, I tried an existing random menu which are the 2 following menus. But I made one work with clean URLs and the other without. The existing menu set with a clean URLs also failed but the same menu which isn't a clean URL worked fine.

Because my localhost installation is not happy to work with clean URLs regardless of what I try, I need a technique to make my module flexible regardless of if the site is working with or without clean URLs (particularly if I end up releasing it).

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top