Ajax post with one parameter How can you pass / as part of a parameter in an Ajax call?

The address is http://studiga.delta-xray.co.uk/delete_favourites/%3Cspan%20class%3D%22remove-favourite%22%3E%26nbsp%3B%3C%2Fspan%3E%3Ca%20class%3D%22title%22%20href%3D%22http%3A%2F%2Fstudiga.delta-xray.co.uk%2Fproperties%2Fliverpool-property%22%3ELiverpool%20property%20Address%20line%201%3C%2Fa%3E%3Cspan%20class%3D%22address%22%3E%20Address%20line%202%20Town%20L2%206RE%3C%2Fspan%3E and I wanted just one parameter, but it is treating %2F as /.

function delete_favourites_permission() {
  return array(
    'access favourites content' =&gt; array(
      'title' =&gt; t('delete favourites via ajax'),
    )
  );
}

function delete_favourites_menu () {
  $items = array();
  $items['delete_favourites'] = array(
    'page callback' =&gt; 'delete_favourites_page',
    'access arguments' =&gt; array('delete_favourites_permission'),
    'page arguments' =&gt; array(1),
    'access callback' =&gt; TRUE,
    'type' =&gt; MENU_CALLBACK,
  );

  return $items;
}

function delete_favourites_page($line) {
    echo $line;

    $result = "vvvv";
    drupal_json_output($result);
    exit();
} 


echo $line; prints &lt;span class="remove-favourite"&gt;&amp;nbsp;.

How can I get it to work?
What I think you are trying to do is delete a record from the database, someones 'favorite', like a bookmark on content, perhaps.

Anyway, what you need is an argument in the URL, the best being an ID - even better if it is an entity id that could be provided as a loaded argument for you (like node/%node - the %node argument provides the loaded node instead of just node id).

Assuming the argument is simply an integer of a database record, you could do:

function delete_favourites_menu () {
  $items = array();
  $items['delete_favourites/%'] = array(
    'page callback' =&gt; 'delete_favourites_page',
    'access arguments' =&gt; array('delete_favourites_permission'),
    'page arguments' =&gt; array(1),
    'access callback' =&gt; TRUE,
    'delivery callback' =&gt; 'ajax_deliver',
  );

  return $items;
}

function delete_favourites_page($favorite_id) {
    // code to delete the favorite_id record
    $commands = array();
    $commands[] = ajax_command_alert('Favorite has been deleted.');
  return array('#type' =&gt; 'ajax', '#commands' =&gt; $commands);
} 


However, your access callback should not be TRUE, that means anyone can hit this URL and there is no upfront access checking. I hope you are handling that in your callback, but ideally you should use permissions or a callback to perform more complex checking.

The ID will always be passed to the page callback function now, and you could perform the delete operation there.

The delivery callback has been set as ajax deliver, which tells Drupal the page will return ajax commands. The above code contains a very simple alert, which will fire when the callback is performed.

There is a decent amount more that can go into this when wanting to implement AJAX interactions via menu items and callbacks. But first you need to figure out / fix your URL structure so you can pass arguments and not strings / query strings, and you'll also want to implement access checking so only the user who owns that record (or admin) can delete it.