Can't get Ajax data sent to my PHP function I recently took over an existing Drupal project and I tried to add a new PHP function (which works regularly) and link it with an Ajax query. There were already some in place that worked, and I wanted to add one that when you press a link, it sends the ID in the link to a PHP function which generates an info field. By copying the working code I got to this:

In my module, I added a menu hook referring to the PHP function in the module and the Ajax link:

$items['api/feedback'] = array(
  'page callback' =&gt; 'admin_user_feedback',
  'access arguments' =&gt; array('access feedback'),
  'access callback' =&gt; TRUE
);

return $items; 


This is my Ajax code:

function getFeedback(id){
    $.ajax({
        type: "POST",
        url: 'api/feedback',
        dataType: 'json',
        data: {
            'id': id,
        },
        success: function(data){

            alert("success");
        },
        error: function(){

            alert("error");
        },
    });
}


I know the function gets called on, but the console gives this error:


  POST http://localhost:8080/site/api/feedback 404 (Not Found)


The URL is correct, the other APIs with similar URLs do work, so somehow he doesn't recognise this API, I must have missed something. Does anybody know?
Check your URL again...  should it have /site/ ?   I am guessing not, unless you have something going on it should be:   http://localhost:8080/api/feedback

url: '/api/feedback',