Ajax %-wildcard URL giving 404 error when setting a parameter I have a page with a dropdown. When you click on that dropdown that content is loaded by Ajax. I would like to do the same for the Breadcrumb, so I created an Ajax-URL in my module:

function selectexamfeature_menu() {
  $items = array();
  $items['selectexamfeature/ajax-replace-breadcrumb/%'] = array(
      'title' =&gt; 'Ajax-Callback for replacing breadcrumb',
      'page callback' =&gt; 'selectexamfeature_ajax_callback',
      'page arguments' =&gt; array(2),
      'access arguments' =&gt; array('access content'),
      'type' =&gt; MENU_CALLBACK,
  );
  return $items;
}

function selectexamfeature_ajax_callback($url){
  $commands = array();
    // later on the $url will be used here for generating the breadcrumb html
  $ret = $url;
  $commands[] = ajax_command_html('.page-breadcrumb', $ret);
  $page = array('#type' =&gt; 'ajax', '#commands' =&gt; $commands);
  ajax_deliver($page);
}


and in my Javascript code I have:

  var custom_settings = {};
  custom_settings.url = '/selectexamfeature/ajax-replace-breadcrumb/SOMELINKASSTRING';
  custom_settings.keypress = false;
  custom_settings.prevent = false;
  Drupal.ajax['custom_ajax_action'] = new Drupal.ajax(null, $(document.body), custom_settings);

  Drupal.behaviors.selectexamfeature_ajax_replace_breadcrumb = {
    attach: function (context, settings) {
      $( "#edit-field-text-grade-tid" ).change(function() {
        // the event...
      });
    }
  };


So at the end I want to get the SOMELINKASSTRING in my $ret variable. But for now I just get a 404 error all the time:


  An AJAX HTTP error occurred. 
  HTTP response code: 404 
  Debugg information follows: /selectexamfeature/ajax-replace-breadcrumb/SOMELINKASSTRING Statustext: Not Found...


I believe the issue is in the wildcard section. Somehow it does not replace it correctly.

If I leave the % away and also the SOMELINKASSTRING it works without issues. But I for sure need the parameter to know which page is requested.

Also watch this awesome article but it did not help either.
If the form is part of a standard Drupal form, you can use Drupal's built in AJAX system. There is a detailed explanation here: Ajax Forms in Drupal 7. Basically it should look like this.

function hook_some_form($form, &amp;$form_state) {
  // Create a frop down
  $form['some_select'] = array(
    '#type' =&gt; 'select',
    '#options' =&gt; $options,
    '#default_value' =&gt; $default,
    '#ajax' =&gt; array(
      'callback' =&gt; 'some_ajax_callback', // This is the php function to be called
      'wrapper' =&gt; 'some_wrapper', // The javascript #id to put content in.
      'method' =&gt; 'replace', // Content placement option
    ),
  );

  // Result contents container
  $form['some_wrapper'] = array(
    '#type' =&gt; 'item',
    '#id' =&gt; 'some_wrapper',
    '#tree' =&gt; TRUE,
  );
}


And for the PHP callback

function some_ajax_callback($form, $form_state) {
  // Fetch the value AJAX gave us.
  $value = $form_state['values']['some_select'];

  // Recreate the wrapper as we overwrite the old one.
  $form['some_wrapper'] = array(
    '#type' =&gt; 'item',
    '#id' =&gt; 'some_wrapper',
    '#tree' =&gt; TRUE,
  );

  // Append the value of the drop down to it.
  $form['some_wrapper']['value'] = array(
    '#type' =&gt; 'item',
    '#markup' =&gt; check_plain($value);
  );
  // Return everything to Javascript.
  return $form['some_wrapper']
}


This allows you to pass form values to PHP for processing.